// if (!readline) { var { readline, print } = require('./index.js'); }

const
	ZERO_CHAR_CODE = '0'.charCodeAt();

/**
 * Returns an array of length 10
 * that stores the number of occurrences of each digit in the number
 * @param { string } number
 * @returns { [number] }
 */
function getDigitsNumber(num) {
	var result = new Array(10).fill(0);
	for (var char of num) {
		var digit = char.charCodeAt() - ZERO_CHAR_CODE;
		if (digit >= 0 && digit <= 9) {
			result[digit]++;
		}
	}
	return result;
}

/**
 * Returns an array of digits of number
 * @param { string } number
 * @returns { [number] }
 */
function getDigits(num) {
	var result = new Array(num.length).fill(0);
	for (var i = 0; i < num.length; i++) {
		var digit = num.charCodeAt(i) - ZERO_CHAR_CODE;
		if (digit < 0 || digit > 9) throw 'is not number';
		result[i] = digit;
	}
	return result;
}

/**
 * Returns a number (as string) consisting of digits of a and not exceeding b
 * @param { string } a
 * @param { string } b
 * @returns { string }
 */
function rearrangeNumbers(a, b) {
	var aNums = getDigitsNumber(a);
	var bNums = getDigits(b);
	var result = '';
	if (a.length != b.length) {
		for (var i = 9; i >= 0; i--) result += ('' + i).repeat(aNums[i]);
	} else {
		var rNums = new Array(a.length);
		var ind, lastInd;
		ind = lastInd = 0;
		var isLess = false;
		for (var i = 0; i < a.length; i++) {
			var needToBreak = true;
			var iFrom = isLess ? 9 : bNums[i];
			for (var j = iFrom; j >= 0; j--) {
				if (aNums[j] > 0) {
					if (j < bNums[i]) {
						isLess = true;
						lastInd = i;
					}
					ind = i;
					rNums[i] = j;
					aNums[j]--;
					needToBreak = false;
					break;
				}
			}
			if (needToBreak) break;
		}
		var backStep = false;
		while (ind + 1 < a.length) {
			var needToStepBack = true;
			var iFrom = backStep ? rNums[ind + 1] - 1 : isLess ? 9 : bNums[ind + 1];
			for (var i = iFrom; i >= 0; i--) {
				if (aNums[i] > 0) {
					aNums[i]--;
					ind++;
					if (!isLess && i < bNums[ind]) {
						isLess = true;
						lastInd = ind;
					}
					rNums[ind] = i;
					backStep = false;
					needToStepBack = false;
					break;
				}
			}
			if (needToStepBack) {
				aNums[rNums[ind]]++;
				ind--;
				backStep = true;
				// if (isLess && ind < lastInd) {
				if (isLess && ind == lastInd) {
					isLess = false;
				}
			}
		}
		for (var i = 0; i < a.length; i++) {
			result += '' + rNums[i]
		}
	}
	return result;
}

function main() {
	var a = readline();
	var b = readline();
	print(rearrangeNumbers(a, b));
}

main();

var aOrig = readline();
var bOrig = readline();
var bIsLonger = false;
var prevIsBigger = false;

if (aOrig.length < bOrig.length) {
    bOrig = bOrig.substr(0, aOrig.length);
    bIsLonger = true;
}

var a = aOrig.split('');
var b = bOrig.split('');

var map = {
    0: 0,
    1: 0,
    2: 0,
    3: 0,
    4: 0,
    5: 0,
    6: 0,
    7: 0,
    8: 0,
    9: 0
};

var result = '';

function findMax(e) {
    var origE = e;
    if (bIsLonger || typeof prevIsBigger === 'number') {
        // print("wtf..." + prevIsBigger)
        e = 9;
    }
    while(e > -1) {
        if (map[e]) {
            map[e]--;
            // print(result + e);
            return e;
        }
        e--;
        if (prevIsBigger === false) {
            prevIsBigger = result.length;
        }
    }
    var prev = result[result.length - 1];
    map[prev]++;
    // print("ye boi" + prevIsBigger + " " + (result.length))
    if (prevIsBigger === result.length) {
        prevIsBigger = false;
    }
    result = result.substring(0, result.length - 1);
    // print(result);
    //THIS S***!!!!!!!!!!
    var q = findMax(prev - 1);
    result += q;
    // print(">> " + result);
    prevIsBigger = result.length;
    return findMax(origE);

}

a.forEach(e => {
    map[e]++;
});
b.forEach(e => {
    var c = findMax(e);
    result += c;
    //2 lines above are not the same as below!!!!!!
    //result += findMax(e);
    // print("> " + result)
});

print(result);

a = readline();
b = readline();
cnt = Array(10).fill(0);
for (c of a) cnt[c]++;
lo = hi = "";
for (c of a.length < b.length ? "9999999999999999999" : b) {
    for (i = c - 1; i >= 0; i--)
        if (cnt[i]) {
            lo = hi + i;
            cnt[i]--;
            for (j = 9; j >= 0; j--) {
                for (k = cnt[j]; k; k--) lo += j;
            }
            cnt[i]++;
            break;
        }
    if (!cnt[c]) break;
    hi += c;
    cnt[c]--;
}
print(lo.length > hi.length ? lo : hi);

var aOrig = readline();
var bOrig = readline();
var bIsLonger = false;
var prevIsBigger = false;

if (aOrig.length < bOrig.length) {
    bOrig = bOrig.substr(0, aOrig.length);
    bIsLonger = true;
}

var a = aOrig.split('');
var b = bOrig.split('');

var map = {
    0: 0,
    1: 0,
    2: 0,
    3: 0,
    4: 0,
    5: 0,
    6: 0,
    7: 0,
    8: 0,
    9: 0
};

var result = '';

function findMax(e) {
    var origE = e;
    if (bIsLonger || prevIsBigger) {
        e = 9;
    }
    while(e > -1) {
        if (map[e]) {
            map[e]--;
            // print(result + e);
            return e;
        }
        e--;
        if (!prevIsBigger) {
            prevIsBigger = result.length - 1;
        }
    }
    var prev = result[result.length - 1];
    // print("===");
    map[prev]++;
    if (prevIsBigger >= result.length - 2) {
        prevIsBigger = false;
    }
    result = result.substring(0, result.length - 1);
    // print(result);
    result += findMax(prev - 1);
    // print(">> " + result);
    prevIsBigger = result.length - 2;
    return findMax(origE);

}

a.forEach(e => {
    map[e]++;
});
b.forEach(e => {
    var c = findMax(e);
    result += c;
    //2 lines above are not the same as below!!!!!!
    //result += findMax(e);
    // print("> " + result)
});

print(result);

var aOrig = readline();
var bOrig = readline();
var bIsLonger = false;
var prevIsLonger = false;

if (aOrig.length < bOrig.length) {
    bOrig = bOrig.substr(0, aOrig.length);
    bIsLonger = true;
}

var a = aOrig.split('');
var b = bOrig.split('');

var map = {
    0: 0,
    1: 0,
    2: 0,
    3: 0,
    4: 0,
    5: 0,
    6: 0,
    7: 0,
    8: 0,
    9: 0
};

var result = '';

function findMax(e) {
    if (bIsLonger || prevIsLonger) {
        e = 9;
    }
    var origE = e;
    while(e > -1) {
        if (map[e]) {
            map[e]--;
            if (origE === e) {
                prevIsLonger = false;
            }
            return e;
        }
        e--;
        prevIsLonger = true;
        if (e < 0) {
            e = 9;
        }
    }
}

a.forEach(e => {
    map[e]++;
});
b.forEach(e => result += findMax(e));

print(result);

var aOrig = readline();
var bOrig = readline();
var bIsLonger = false;
var prevIsBigger = false;

if (aOrig.length < bOrig.length) {
    bOrig = bOrig.substr(0, aOrig.length);
    bIsLonger = true;
}

var a = aOrig.split('');
var b = bOrig.split('');

var map = {
    0: 0,
    1: 0,
    2: 0,
    3: 0,
    4: 0,
    5: 0,
    6: 0,
    7: 0,
    8: 0,
    9: 0
};

var result = '';

function findMax(e) {
    var origE = e;
    if (bIsLonger || typeof prevIsBigger === 'number') {
        // print("wtf..." + prevIsBigger)
        e = 9;
    }
    while(e > -1) {
        if (map[e]) {
            map[e]--;
            // print(result + e);
            return e;
        }
        e--;
        if (prevIsBigger === false) {
            prevIsBigger = result.length;
        }
    }
    var prev = result[result.length - 1];
    // print("===");
    // if(result) {
    //
    //     print(result);
    // }
    map[prev]++;
    if (prevIsBigger >= result.length - 1) {
        prevIsBigger = false;
    }
    result = result.substring(0, result.length - 1);
    // print(result);
    result += findMax(prev - 1);
    // print(">> " + result);
    prevIsBigger = result.length - 2;
    return findMax(origE);

}

a.forEach(e => {
    map[e]++;
});
b.forEach(e => {
    var c = findMax(e);
    result += c;
    //2 lines above are not the same as below!!!!!!
    //result += findMax(e);
    // print("> " + result)
});

print(result);

var aOrig = readline();
var bOrig = readline();
var bIsLonger = false;
var prevIsBigger = false;

if (aOrig.length < bOrig.length) {
    bOrig = bOrig.substr(0, aOrig.length);
    bIsLonger = true;
}

var a = aOrig.split('');
var b = bOrig.split('');

var map = {
    0: 0,
    1: 0,
    2: 0,
    3: 0,
    4: 0,
    5: 0,
    6: 0,
    7: 0,
    8: 0,
    9: 0
};

var result = '';

function findMax(e) {
    var origE = e;
    if (bIsLonger || prevIsBigger) {
        e = 9;
    }
    while(e > -1) {
        if (map[e]) {
            map[e]--;
            if (origE === e) {
                prevIsBigger = false;
            }
            return e;
        }
        e--;
        prevIsBigger = true;
    }
    map[result[result.length - 1]]++;
    var prev = result[result.length - 1];
    result = result.substring(0, result.length - 1);
    result += findMax(prev - 1);
    return findMax(origE - 1);

}

a.forEach(e => {
    map[e]++;
});
b.forEach(e => result += findMax(e));

print(result);

var aOrig = readline();
var bOrig = readline();
var bIsLonger = false;
var prevIsLonger = false;

if (aOrig.length < bOrig.length) {
    bOrig = bOrig.substr(0, aOrig.length);
    bIsLonger = true;
}

var a = aOrig.split('');
var b = bOrig.split('');

var map = {
    0: 0,
    1: 0,
    2: 0,
    3: 0,
    4: 0,
    5: 0,
    6: 0,
    7: 0,
    8: 0,
    9: 0
};

var result = '';

function findMax(e) {
    var origE = e;
    if (bIsLonger || prevIsLonger) {
        e = 9;
    }
    while(e > -1) {
        if (map[e]) {
            map[e]--;
            if (origE === e) {
                prevIsLonger = false;
            }
            return e;
        }
        e--;
        prevIsLonger = true;
        if (e < 0) {
            e = 9;
        }
    }
}

a.forEach(e => {
    map[e]++;
});
b.forEach(e => result += findMax(e));

print(result);

// if (!readline) { var { readline, print } = require('./index.js'); }

const
	ZERO_CHAR_CODE = '0'.charCodeAt();

/**
 * Returns an array of length 10
 * that stores the number of occurrences of each digit in the number
 * @param { string } number
 * @returns { [number] }
 */
function getDigitsNumber(num) {
	var result = new Array(10).fill(0);
	for (var char of num) {
		var digit = char.charCodeAt() - ZERO_CHAR_CODE;
		if (digit >= 0 && digit <= 9) {
			result[digit]++;
		}
	}
	return result;
}

/**
 * Returns an array of digits of number
 * @param { string } number
 * @returns { [number] }
 */
function getDigits(num) {
	var result = new Array(num.length).fill(0);
	for (var i = 0; i < num.length; i++) {
		var digit = num.charCodeAt(i) - ZERO_CHAR_CODE;
		if (digit < 0 || digit > 9) throw 'is not number';
		result[i] = digit;
	}
	return result;
}

/**
 * Returns a number (as string) consisting of digits of a and not exceeding b
 * @param { string } a
 * @param { string } b
 * @returns { string }
 */
function rearrangeNumbers(a, b) {
	var aNums = getDigitsNumber(a);
	var bNums = getDigits(b);
	var result = '';
	if (a.length != b.length) {
		for (var i = 9; i >= 0; i--) result += ('' + i).repeat(aNums[i]);
	} else {
		var rNums = new Array(a.length);
		var ind, lastInd;
		ind = lastInd = 0;
		var isLess = false;
		for (var i = 0; i < a.length; i++) {
			var needToBreak = true;
			var iFrom = isLess ? 9 : bNums[i];
			for (var j = iFrom; j >= 0; j--) {
				if (aNums[j] > 0) {
					if (j < bNums[i]) {
						isLess = true;
						lastInd = i;
					}
					ind = i;
					rNums[i] = j;
					aNums[j]--;
					needToBreak = false;
					break;
				}
			}
			if (needToBreak) break;
		}
		var backStep = false;
		while (ind + 1 < a.length) {
			var needToStepBack = true;
			var iFrom = backStep ? rNums[ind + 1] - 1 : isLess ? 9 : bNums[ind + 1];
			for (var i = iFrom; i >= 0; i--) {
				if (aNums[i] > 0) {
					aNums[i]--;
					if (!isLess && i < bNums[ind]) {
						isLess = true;
						lastInd = ind;
					}
					ind++;
					rNums[ind] = i;
					backStep = false;
					needToStepBack = false;
					break;
				}
			}
			if (needToStepBack) {
				aNums[rNums[ind]]++;
				ind--;
				backStep = true;
				// if (isLess && ind < lastInd) {
				if (isLess && ind == lastInd) {
					isLess = false;
				}
			}
		}
		for (var i = 0; i < a.length; i++) {
			result += '' + rNums[i]
		}
	}
	return result;
}

function main() {
	var a = readline();
	var b = readline();
	print(rearrangeNumbers(a, b));
}

main();

// if (!readline) { var { readline, print } = require('./index.js'); }

const
	ZERO_CHAR_CODE = '0'.charCodeAt();

/**
 * Returns an array of length 10
 * that stores the number of occurrences of each digit in the number
 * @param { string } number
 * @returns { [number] }
 */
function getDigitsNumber(num) {
	var result = new Array(10).fill(0);
	for (var char of num) {
		var digit = char.charCodeAt() - ZERO_CHAR_CODE;
		if (digit >= 0 && digit <= 9) {
			result[digit]++;
		}
	}
	return result;
}

/**
 * Returns an array of digits of number
 * @param { string } number
 * @returns { [number] }
 */
function getDigits(num) {
	var result = new Array(num.length).fill(0);
	for (var i = 0; i < num.length; i++) {
		var digit = num.charCodeAt(i) - ZERO_CHAR_CODE;
		if (digit < 0 || digit > 9) throw 'is not number';
		result[i] = digit;
	}
	return result;
}

/**
 * Returns a number (as string) consisting of digits of a and not exceeding b
 * @param { string } a
 * @param { string } b
 * @returns { string }
 */
function rearrangeNumbers(a, b) {
	var aNums = getDigitsNumber(a);
	var bNums = getDigits(b);
	var result = '';
	if (a.length != b.length) {
		for (var i = 9; i >= 0; i--) result += ('' + i).repeat(aNums[i]);
	} else {
		var rNums = new Array(a.length);
		var ind, lastInd;
		ind = lastInd = 0;
		var isLess = false;
		for (var i = 0; i < a.length; i++) {
			var needToBreak = true;
			var iFrom = isLess ? 9 : bNums[i];
			for (var j = iFrom; j >= 0; j--) {
				if (aNums[j] > 0) {
					if (j < bNums[i]) {
						isLess = true;
						lastInd = i;
					}
					ind = i;
					rNums[i] = j;
					aNums[j]--;
					needToBreak = false;
					break;
				}
			}
			if (needToBreak) break;
		}
		var backStep = false;
		while (ind + 1 < a.length) {
			var needToStepBack = true;
			var iFrom = backStep ? rNums[ind + 1] - 1 : isLess ? 9 : bNums[ind + 1];
			for (var i = iFrom; i >= 0; i--) {
				if (aNums[i] > 0) {
					aNums[i]--;
					ind++;
					rNums[ind] = i;
					if (!isLess && i < iFrom) {
						isLess = true;
						lastInd = ind;
					}
					backStep = false;
					needToStepBack = false;
					break;
				}
			}
			if (needToStepBack) {
				aNums[rNums[ind]]++;
				ind--;
				backStep = true;
				// if (isLess && ind < lastInd) {
				if (isLess && ind == lastInd) {
					isLess = false;
				}
			}
		}
		for (var i = 0; i < a.length; i++) {
			result += '' + rNums[i]
		}
	}
	return result;
}

function main() {
	var a = readline();
	var b = readline();
	print(rearrangeNumbers(a, b));
}

main();

// if (!readline) { var { readline, print } = require('./index.js'); }

const
	ZERO_CHAR_CODE = '0'.charCodeAt();

/**
 * Returns an array of length 10
 * that stores the number of occurrences of each digit in the number
 * @param { string } number
 * @returns { [number] }
 */
function getDigitsNumber(num) {
	var result = new Array(10).fill(0);
	for (var char of num) {
		var digit = char.charCodeAt() - ZERO_CHAR_CODE;
		if (digit >= 0 && digit <= 9) {
			result[digit]++;
		}
	}
	return result;
}

/**
 * Returns an array of digits of number
 * @param { string } number
 * @returns { [number] }
 */
function getDigits(num) {
	var result = new Array(num.length).fill(0);
	for (var i = 0; i < num.length; i++) {
		var digit = num.charCodeAt(i) - ZERO_CHAR_CODE;
		if (digit < 0 || digit > 9) throw 'is not number';
		result[i] = digit;
	}
	return result;
}

/**
 * Returns a number (as string) consisting of digits of a and not exceeding b
 * @param { string } a
 * @param { string } b
 * @returns { string }
 */
function rearrangeNumbers(a, b) {
	var aNums = getDigitsNumber(a);
	var bNums = getDigits(b);
	var result = '';
	if (a.length != b.length) {
		for (var i = 9; i >= 0; i--) result += ('' + i).repeat(aNums[i]);
	} else {
		var rNums = new Array(a.length);
		var ind, lastInd;
		ind = lastInd = 0;
		var isLess = false;
		for (var i = 0; i < a.length; i++) {
			var needToBreak = true;
			var iFrom = isLess ? 9 : bNums[i];
			for (var j = iFrom; j >= 0; j--) {
				if (aNums[j] > 0) {
					if (j < bNums[i]) {
						isLess = true;
						lastInd = i;
					}
					ind = i;
					rNums[i] = j;
					aNums[j]--;
					needToBreak = false;
					break;
				}
			}
			if (needToBreak) break;
		}
		while (ind + 1 < a.length) {
			var needToStepBack = true;
			var iFrom = isLess ? 9 : bNums[ind + 1];
			for (var i = iFrom; i >= 0; i--) {
				if (aNums[i] > 0) {
					aNums[i]--;
					ind++;
					rNums[ind] = i;
					if (!isLess && i < iFrom) {
						isLess = true;
						lastInd = ind;
					}
					needToStepBack = false;
				}
			}
			if (needToStepBack) {
				aNums[rNums[ind]]++;
				ind--;
				if (isLess && ind == lastInd) {
					isLess = false;
				}
			}
		}
		for (var i = 0; i < a.length; i++) {
			result += '' + rNums[i]
		}
	}
	return result;
}

function main() {
	var a = readline();
	var b = readline();
	print(rearrangeNumbers(a, b));
}

main();

a = readline();
b = readline();
if (a.length < b.length) b = Array(a.length).fill(9);
cnt = Array(10).fill(0);
for (c of a) cnt[+c]++;
lo = hi = 0;
for (c of b) {
    d = +c;
    for (i = d - 1; i >= 0; i--) {
        if (cnt[i]) {
            lo = hi * 10 + i;
            cnt[i]--;
            for (j = 9; j >= 0; j--) {
                for (k = cnt[j]; k; k--) lo = lo * 10 + j;
            }
            cnt[i]++;
            break;
        }
    }
    if (cnt[d]) {
        hi = hi * 10 + d;
        cnt[d]--;
    } else break;
}
print(lo < hi ? hi : lo);


function main(){
  var line = readline().split(" ").map(Number);
  var barriers = line[0];
  var trackLength = line[1];

  if(barriers === 1)
    return print("YES");

  var kefaBarriers = readline().split(" ").map(Number).map(function(e, i, ar){
    return i === ar.length - 1 ? trackLength + ar[0] - e : ar[i+1] - e;
  });
  var sashaBarriers = readline().split(" ").map(Number).map(function(e, i, ar){
    return i === ar.length - 1 ? trackLength + ar[0] - e : ar[i+1] - e;
  });

  for(var i = 0; i < barriers; i++){
    if(sashaBarriers[i] === kefaBarriers[0])
      for(j = i + 1; j < barriers + i; j++){
        if(sashaBarriers[j%barriers] !== kefaBarriers[j-i])
          break;
        else
            if(j-i === barriers - 1)
              return print("YES");
      }
  }

  return print("NO");
}

main();

function main() {
    var data = readline().split(' ').map(Number);
    var first = readline().split(' ').map(Number);
    var second = readline().split(' ').map(Number);
    var L = data[1];
    var n = data[0];

   for(var i=0;i<L;i++){
       var newArray = [];
       for(var j=0;j<n;j++){
           var value =first[j] - i
           if(value < 0){
               value += L
           }

           newArray.push(value);
       }
       newArray.sort((a,b) => a -b);
       var good = true;
       for(var j=0;j<n;j++){
           if(second[j] != newArray[j]){
               good = false;
               break;
           }
       }
       if(good){
           return print("YES");
       }
   }
    return print("NO");
}

main()


Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    myout("No");
}

var x = readline();
x && print('standard output')

var x = readline();
(x === 'standard input') ? print('standard output') : print('');

//var input = readline();
print("Is it rated");

//var input = readline();
print("Is it rated?");


String.prototype.insert = function (index, string) {
  if (index > 0)
    return this.substring(0, index) + string + this.substring(index, this.length);
  else
    return string + this;
};
String.prototype.reverse= function(){
    return this.split('').reverse().join('');
}

function solve(){
    var s = readline();
    var alphabet = "abcdefghijklmnopqrstuvwxyz".split("");
    for(var i = 0; i <= s.length; ++i){
        for(var j = 0; j < alphabet.length; ++j){
            var s1 = s.insert(i,alphabet[j]);
            var s2 = s1.reverse();
            if(s1 == s2){
                print(s1);
                return;
            }
        }
    }
    print("NA");
}
solve();

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
rl.question("", function(word) {
    let ans = word.split('')
    let j = ans.length - 1;
    let ans2 = ans.join('');
    let found = false
    for(let i = 0; !found  && i < ans.length; i++){
        for(let j = 0; j < ans.length; j++){
            let ans1 = ans2.slice(0, i) + ans[j] + ans2.slice(i, ans.length )
            if(checkPolindrom(ans1)){
                found = true;
                console.log(ans1);
                break;
            }
        }
    }

    for(let i = 0; !found  && i < ans.length; i++){
        if(ans[i] !== ans[j]){
            let ans1 = ans2 + ans[j];
            if(checkPolindrom(ans1)){
                found = true
                console.log(ans1)
                break;
            }
            ans1 = ans[j] + ans2;
            if(checkPolindrom(ans1)){
                found = true
                console.log(ans1)
                break;
            }
            ans1 = ans[i] + ans2;
            if(checkPolindrom(ans1)){
                found = true
                console.log(ans1)
                break;
            }
            ans1 = ans2 + ans[i];
            if(checkPolindrom(ans1)){
                found = true
                console.log(ans1)
                break;
            }
        }
    }
    if(!found)
        console.log('NA')
    process.exit(0)
})

rl.on("close", function() {
    console.log("\nBYE BYE !!!");
    process.exit(0);
});

function checkPolindrom(ans1){
    var splitString = ans1.split("");
    var reverseArray = splitString.reverse();
    let check = reverseArray.join("");
    return check === ans1;
}

(function() {

var alpha = "abcdefghijklmnopqrstuvwxyz";
var str = readline();

for(var i = 0; i <= str.length; i++) {
    for(var j = 0; j < alpha.length; j++) {
        var res = str.substr(0,i)+alpha[j]+str.substr(i);
        if(isPalin(res))
            return print(res);
    }
}

print("NA");

function isPalin(s) {
    for(var i = 0; i < s.length/2; i++) {
        if(s[i] !== s[s.length-1-i])
            return false;
    }
    return true;
}

})();


"use strict";

// var inp = prompt().split(" ").map(function(x) { return parseInt(x); });
var inp = readline().split(" ").map(function(x) { return parseInt(x); });
var a = inp[0];
var b = inp[1];
var x = inp[2];
var s = ""

var flag;
if (a <= b)
    flag = "1"
    else
    flag = "0";

    for(var i = 0; i < x; i++){
        s+=flag;

        if (flag == "0") flag = "1"
        else flag = "0";
    }

    flag = s[s.length - 1];
    var flagCount = 0;
    for (var i = 0; i < s.length; i++)
        if (s[i] == flag) flagCount++;

    var q = (flag == "0") ? a : b;
    for (var i = flagCount; i < q; i++)
        s += flag;

    if (flag == "0") flag = "1"
        else flag = "0";
    q = (flag == "0") ? a : b;

    flagCount = 0;
    for (var i = 0; i < s.length; i++)
        if (s[i] == flag) flagCount++;
    for (var i = flagCount; i < q; i++)
        s += flag;

// console.log(s);
print(s);

function main() {
  const is = new Scanner();
  let [a, b, x] = is.nextArray().map(Number);
  const binaryString = new Int32Array(x + 1);

  for (let i = a > b ? 1 : 0; i < binaryString.length; i += 2)
    binaryString[i] = 1;

  let zeros = 0, ones = 0;
  binaryString.forEach((item) => {
    if (item)
      ones++;
    else
      zeros++;
  });

  a -= zeros;
  b -= ones;

  for (let i = 0; i < 2; i++) {
    if (binaryString[i] === 0) {
      for (let j = 0; j < a; j++)
        process.stdout.write('0');
    } else {
      for (let j = 0; j < b; j++)
        process.stdout.write('1');
    }
    process.stdout.write(String(binaryString[i]));
  }

  for (let i = 2; i < binaryString.length; i++)
    process.stdout.write(String(binaryString[i]));
}

/*
 *  api stdin
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n');
  }

  nextLine() {
    return this.lines[this.index++];
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', input => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

var firstLine = readline().split(' ').map(function(v){return +v;});

var zeroCount = firstLine[0] - 1;
var oneCount = firstLine[1] - 1;
var xCount = firstLine[2] - 1;

var zero = "0";
var one = "1";
var param = false;
var resultString = one + zero;

while(xCount > 0) {
    if (oneCount === 0 || zeroCount === 0) break;

    if (param) {
        param = !param;
        resultString = resultString + zero;
        zeroCount -= 1;
    } else {
        param = !param;
        resultString = resultString + one;
        oneCount -= 1;
    }

    xCount -= 1;
}

if (xCount > 0 && zeroCount > 0) {
    resultString = zero + resultString;
    zeroCount -= 1;
}

if (xCount > 0 && oneCount > 0) {
    resultString = resultString + one;
    oneCount -= 1;
}

if (xCount === 0 && resultString[resultString.length - 1] === one) {
    resultString = one.repeat(oneCount) + resultString.slice(0, -1) + zero.repeat(zeroCount) + resultString[resultString.length - 1];
} else {
    resultString = one.repeat(oneCount) + resultString + zero.repeat(zeroCount);
}

print(resultString);

var line = readline ();
line = line.trim ().split ( ' ' );
var a = (+ line [ 0 ]), b = (+ line [ 1 ]), x = (+ line [ 2 ]);
var result = [ ];
var cnt = 0;
if ( a > b ) {
    result.push ( '0' );
    a --;
    while ( cnt < x ) {
        if ( cnt % 2 == 1 ) {
            result.push ( '0' );
            a --;
        } else {
            result.push ( '1' );
            b --;
        }
        cnt ++;
    }
} else {
    result.push ( '1' );
    b --;
    while ( cnt < x ) {
        if ( cnt % 2 == 0 ) {
            result.push ( '0' );
            a --;
        } else {
            result.push ( '1' );
            b --;
        }
        cnt ++;
    }
}
var pos;
pos = result.indexOf ( '0' );
while ( a > 0 ) {
    result.splice ( pos, 0, '0' );
    a --;
}
pos = result.indexOf ( '1' );
while ( b > 0 ) {
    result.splice ( pos, 0, '1' );
    b --;
}
var str = '';
for ( var g = 0; g < result.length; g ++ ) { str += result [ g ]; }
print ( str );

var firstLine = readline().split(' ').map(function(v){return +v;});

var zeroCount = firstLine[0] - 1;
var oneCount = firstLine[1] - 1;
var xCount = firstLine[2] - 1;

var zero = "0";
var one = "1";
var param = false;
var resultString = one + zero;

while(xCount > 0) {
    if (oneCount === 0 || zeroCount === 0) break;

    if (param) {
        param = !param;
        resultString = resultString + zero;
        zeroCount -= 1;
    } else {
        param = !param;
        resultString = resultString + one;
        oneCount -= 1;
    }

    xCount -= 1;
}

if (xCount > 0 && zeroCount > 0) {
    resultString = zero + resultString;
    zeroCount -= 1;
}

if (xCount > 0 && oneCount > 0) {
    resultString = resultString + one;
    oneCount -= 1;
}

if (xCount === 0 && resultString[resultString.length - 1] !== one) {
    resultString = one.repeat(oneCount) + resultString + zero.repeat(zeroCount);
} else {
    resultString = one.repeat(oneCount) + resultString.slice(0, -1) + zero.repeat(zeroCount) + resultString[resultString.length - 1];
}

print(resultString);

var firstLine = readline().split(' ').map(function(v){return +v;});

var zeroCount = firstLine[0] - 1;
var oneCount = firstLine[1] - 1;
var xCount = firstLine[2] - 1;

var zero = "0";
var one = "1";
var param = false;
var resultString = one + zero;

while(xCount > 0) {
    if (oneCount === 0 || zeroCount === 0) break;

    if (param) {
        param = !param;
        resultString = resultString + zero;
        zeroCount -= 1;
    } else {
        param = !param;
        resultString = resultString + one;
        oneCount -= 1;
    }

    xCount -= 1;
}

if (xCount > 0 && zeroCount > 0) {
    resultString = zero + resultString;
    zeroCount -= 1;
}

if (xCount > 0 && oneCount > 0) {
    resultString = resultString + one;
    oneCount -= 1;
}

resultString = one.repeat(oneCount) + resultString + zero.repeat(zeroCount);

print(resultString);

function main() {
  const is = new Scanner();
  let [a, b, x] = is.nextArray().map(Number);
  console.log(a, b, x);
  const binaryString = new Int32Array(x + 1);

  for (let i = a > b ? 1 : 0; i < binaryString.length; i += 2)
    binaryString[i] = 1;

  let zeros = 0, ones = 0;
  binaryString.forEach((item) => {
    if (item)
      ones++;
    else
      zeros++;
  });

  a -= zeros;
  b -= ones;

  for (let i = 0; i < 2; i++) {
    if (binaryString[i] === 0) {
      for (let j = 0; j < a; j++)
        process.stdout.write('0');
    } else {
      for (let j = 0; j < b; j++)
        process.stdout.write('1');
    }
    process.stdout.write(String(binaryString[i]));
  }

  for (let i = 2; i < binaryString.length; i++)
    process.stdout.write(String(binaryString[i]));
}

/*
 *  api stdin
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n');
  }

  nextLine() {
    return this.lines[this.index++];
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', input => { stdinInput += input; });
process.stdin.on('end', () => { main(); });


var input = Number(readline());
var quantity = Math.floor((Math.pow(1 + 4 * 2 * input, 0.5) - 1) / 2);
var sum = 0;
var numbers = [];
for (var i = 1; i < quantity; i++) {
	sum += i;
	numbers.push(i);
}
numbers.push(input - sum);
print("" + quantity);
print(numbers.join(" "));

var input = readline();
var current = 1;
var sum = 0;

recurse();

var output = [];

for(var i = 1; i < current; i++){
    output.push(i);
}

if(sum > input){
    var diff = sum - input;
    output.splice(output.indexOf(diff), 1);
}

function recurse(){
    if(sum < input){
        sum = sum + current;
        current = current + 1;
        recurse();
    }
}

print(output.length);
print(output.join(" "));

var n = parseInt(readline());
var k = 0;
var num = [];

while(n > k) {

    k++;
    n -= k;
}

for(var i = 1; i < k; i++)
    num.push(i);

num.push(n + k); // push last element

print(k);
print(num.join(" "));

/*
    The idea to solve this problem is:

    repeatedly increase k until n is exhausted, while push value of k to array.
    Add remainder of n to last element of array since it cannot be broken down
    anymore.
*/

var n = parseInt(readline());
var k = 0;
var num = [];

while(n > k) {

    k++;
    n-=k;
    num.push(k);
}

num[num.length - 1] += n;

print(num.length);
print(num.join(" "));

function sa(n){
    var i =1;
    for (; ; i++) {
        if (n < i) return i - 1;
        else n -= i;
    }
}

    var n = Number(readline());
    var res = sa(n)
    print(res);
    var r = ""
    var sum = 0;
    for(var i=0;i<res;i++){
        if(i == res-1){
            r += (n - sum)
            break;
        }
        sum += (i+1);
        r += (i+1) + " ";
    }
    print(r)

var n = parseInt(readline());
var s = 0;
var res = [];
var k = 0;
if(n === 1) {
  print(1);
  print(1);
} else {
  for(var i = 1; i < n; i ++ ) {
    if(i + 1 > n - s - i) {
      res.push(n - s);
      k += 1;
      break;
    } else {
    res.push(i);
      s += i;
      k += 1;
    }
  }
  print(k);
  print(res.join(' '));
}

var n = parseInt(readline());
var i = 1;
var sum = 0;
var num = [];

while((n - sum) > sum) {

    sum += i;
    num.push(i);
    i++;
}

if((n - sum) === num[num.length - 1])
    num[num.length - 1] += (n - sum);
else
    num.push(n - sum);

print(num.length);
print(num.join(" "));

var n = parseInt(readline());
var i = 1;
var sum = 0;
var num = [];

while((n - sum) > sum) {

    sum += i;
    num.push(i);
    i++;
}

if((n - sum) === num[num.length - 1])
    num[num.length - 1] += (n - sum);
else {

    if(n - sum > 0)
        num.push(n - sum);
}

print(num.length);
print(num.join(" "));

var input = Number(readline());
print(Math.floor((Math.pow(1 + 4 * 2 * input, 0.5) - 1) / 2).toString());

var n = parseInt(readline());
var s = 1;
var res = [1];
var k = 1;
for(var i = 2; i < n; i ++ ) {
  if(i + 1 >= n - s - i) {
    res.push(n - s);
    k += 1;
    break;
  } else {
    res.push(i);
    s += i;
    k += 1;
  }
}

print(k);
print(res.join(' '));

var n = parseInt(readline());
var s = 0;
var res = [];
var k = 0;
if(n === 1) {
  print(1);
  print(1);
} else {
  for(var i = 1; i < n; i ++ ) {
    if(i + 1 >= n - s - i) {
      res.push(n - s);
      k += 1;
      break;
    } else {
    res.push(i);
      s += i;
      k += 1;
    }
  }

  print(k);
  print(res.join(' '));

}


var firstLine = readline();
print('\n');

var args = firstLine.split(' ');

print(tort(...args));

function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      var curr = Math.min(Math.floor(x / i), Math.floor(y / (k - i)));
      if (curr > maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

var inputData = readline().split(' ');//prompt("enter 3 argymentf").split(' ');
var bigestDigit = 0;
var tarelkiTortu = inputData[0], kyskiTorta1 = inputData[1], kyskiTorta2 = inputData[2];

    for( var i = 1; i < tarelkiTortu; ++i){
        var calcTort1 = Math.trunc(kyskiTorta1/i);
        var calcTort2 = Math.trunc(kyskiTorta2/(tarelkiTortu - i));
    if(calcTort1 && calcTort2){
        var smallerDigit = Math.min(calcTort1, calcTort2);
       bigestDigit = Math.max(smallerDigit, bigestDigit);
    }
}

print(bigestDigit);//alert("bigestDigit");

var inputData = readline().split(' ').map(Number);//prompt("enter 3 argymentf").split(' ').map(Number);
var bigestDigit = 0;
var tarelkiTortu = inputData[0], kyskiTorta1 = inputData[1], kyskiTorta2 = inputData[2];

    for( var i = 1; i < tarelkiTortu; ++i){
        var calcTort1 = Math.trunc(kyskiTorta1/i);
        var calcTort2 = Math.trunc(kyskiTorta2/(tarelkiTortu - i));
    if(calcTort1 && calcTort2){
        var smallerDigit = Math.min(calcTort1, calcTort2);
       bigestDigit = Math.max(smallerDigit, bigestDigit);
    }
}

print(bigestDigit);//alert("bigestDigit");

var inputData = readline().split(' ').map(Number);//prompt("enter 3 argymentf").split(' ').map(Number);
var bigestDigit = -1;
var tarelkiTortu = inputData[0], kyskiTorta1 = inputData[1], kyskiTorta2 = inputData[2];

    for( var i = 1; i < tarelkiTortu; ++i){
        var calcTort1 = Math.trunc(kyskiTorta1/i);
        var calcTort2 = Math.trunc(kyskiTorta2/(tarelkiTortu - i));
    if(calcTort1 && calcTort2){
        var smallerDigit = Math.min(calcTort1, calcTort2);
       bigestDigit = Math.max(smallerDigit, bigestDigit);
    }
}

print(bigestDigit);//alert("bigestDigit");

_=readline().split(' ').map(Number)
n=_[0],a=_[1],b=_[2]
x=-1
for (var i=1;i<n;++i) {
  var ai=Math.trunc(a/i),
    bi=Math.trunc(b/(n-i))
  if (ai && bi) {
    var y=Math.min(ai, bi)
    x=Math.max(x,y)
  }
}
print(x)

const getMaxPiecesOnPlate = (N, a, b) => {
  var maxPieces = 0;

  for (var i = 1; i < N; i++) {
    maxPieces = Math.max(
      maxPieces,
      Math.min(Math.floor(a / i), Math.floor(b / (N - i)))
    );
  }

  return maxPieces;
};

const main = () => {
  const input = readline()
    .split(" ")
    .map((i) => Number(i));

  return getMaxPiecesOnPlate(input[0], input[1], input[2]);
};

print(main());

var data = readline();
print('\n');

var platesCount = data.split(' ')[0];
var firstCaceParts = data.split(' ')[1];
var secondCakeParts = data.split(' ')[2];

function getMax(n, a, b) {
    var count = 0;

    for (var i = 1; i < n; i++) {
        var current = Math.min(Math.floor(a / i), Math.floor(b / (n - i)));
        if (current > count) {
            count = current;
        }
    }

    return count;
}

print(getMax(platesCount, firstCaceParts, secondCakeParts));

function f(n, u, v) {
    var t = Math.trunc(u * n / (u + v));
    return Math.trunc(t ? v / (n - t) : u);
}

var l = readline().split(' ').map(Number);
var x = f(l[0], l[1], l[2]), y = f(l[0], l[2], l[1]);
print(x > y ? x : y);

var arr = readline().split(' ')
var max = -1;

for (var i = 1; i < arr[0]; i++)
    max = Math.max(max, Math.min(Math.trunc(arr[1]/i), Math.trunc(arr[2]/(arr[0]-i))));

print(max);

const
    conditions = readline().split(' '),
    platesCount = +conditions[0],
    cakes_1 = +conditions[1],
    cakes_2 = +conditions[2];

var
    minCakes = Math.min(cakes_1, cakes_2),
    maxCakes = Math.max(cakes_1, cakes_2);
    minPieces = Math.ceil(maxCakes / Math.ceil(platesCount / 2)),
    plates = [];

while (minPieces > cakes_1 || minPieces > cakes_2) {
    minPieces--;
}

function putCakes() {
    var
        plates = [],
        tmpMinCakes = minCakes,
        tmpMaxCakes = maxCakes;
    for (var i = 0; i < platesCount; i++) {
        if (tmpMaxCakes) {
            if (tmpMaxCakes >= minPieces) {
                plates.push(minPieces)
                tmpMaxCakes -= minPieces;
                if (Math.floor(tmpMaxCakes / minPieces) < 1) {
                    plates[i] += tmpMaxCakes
                    tmpMaxCakes = 0;
                }
            }
        } else {
            if (tmpMinCakes >= minPieces) {
                if (i === platesCount - 1) {
                    plates.push(tmpMinCakes);
                } else {
                    plates.push(minPieces)
                    tmpMinCakes -= minPieces;
                }
            } else {
                plates.push(tmpMinCakes);
            }
        }
    }
    pieces = plates.reduce((a, b) => {return Math.min(a, b)})
    if (pieces < minPieces) {
        minPieces --;
        putCakes();
    } else {
        print(pieces)
    }
}

putCakes()

function main() {
  var data = readline().split(" ");
  var plates = data[0];
  var firstCake = data[1];
  var secondCake = data[2];

  var maxPieces = Math.floor((firstCake + secondCake) / plates);
  var smallCake = Math.min(firstCake, secondCake);
  maxPieces = maxPieces > smallCake ? smallCake : maxPieces;
  if (
    firstCake === 1 ||
    secondCake === 1 ||
    firstCake + secondCake < 2 * plates
  )
    maxPieces = 1;
  else {
    while (
      Math.floor(firstCake / maxPieces) + Math.floor(secondCake / maxPieces) <
      plates
    ) {
      maxPieces--;
    }
  }
  print(maxPieces);
}

main();

var firstLine = readline();
print('\n');

var args = firstLine.split(' ');

print(tort(args[0], args[1], args[2]));

function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      var curr = Math.min(Math.floor(x / i), Math.floor(y / (k - i)));
      if (curr > maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

var inputData = readline().split(' ');
var n = parseInt(inputData[0]);
var a = parseInt(inputData[1]);
var b = parseInt(inputData[2]);
var result = 0;
for (var i = n - 1; i > 0; i--) {
    var maxResult;
    var maxA = Math.floor(a/(n-i));
    var maxB = Math.floor(b/i);
    maxResult = maxA < maxB ? maxA : maxB;
    if (result <= maxResult) {
        result = maxResult;
    } else {
        break;
    }
}
print(result);

var firstLine = readline();
print('\n');

var args = firstLine.split(' ');

print(tort(firstLine.split(' ')[0], firstLine.split(' ')[1], firstLine.split(' ')[2]));

function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      var curr = Math.min(Math.floor(x / i), Math.floor(y / (k - i)));
      if (curr > maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

'use strict';
var incomingData = readline().split(' ');
var n = incomingData[0];
var a = incomingData[1];
var b = incomingData[2];

function f(n, a, b) {
    var x = -1;
    for (var i = 1; i < n; i++) {
        var part_a = Math.trunc(a / i);
        var part_b = Math.trunc(b / (n-i));
        x = Math.max(x, Math.min(part_a, part_b));
    }
    print(x);
}

f(n, a, b);

function tes(e){
    var t911b = e.split(' ');
    var sumPlate = t911b[0];
    var fCake = t911b[1];
    var sCake = t911b[2];
    var res = -1;
    for (var i = 1; i < sumPlate; i++) {
        var f = Math.trunc(fCake / i);
        var s = Math.trunc(sCake / (sumPlate-i));
        res = Math.max(res, Math.min(f, s));
    }
    print(res);
}
tes(readline());

var inputData = readline().split(' ');//prompt("enter 3 argymentf").split(' ').map(Number);
var bigestDigit = 0;
var tarelkiTortu = inputData[0], kyskiTorta1 = inputData[1], kyskiTorta2 = inputData[2];

    for( var i = 1; i < tarelkiTortu; ++i){
        var calcTort1 = Math.trunc(kyskiTorta1/i);
        var calcTort2 = Math.trunc(kyskiTorta2/(tarelkiTortu - i));
    if(calcTort1 && calcTort2){
        var smallerDigit = Math.min(calcTort1, calcTort2);
       bigestDigit = Math.max(smallerDigit, bigestDigit);
    }
}

print(bigestDigit);//alert("bigestDigit");

function f(n, u, v) {
    var t = Math.trunc(u * n / (u + v));
    u /= t;
    v /= n - t;
    return Math.trunc(u < v ? u : v);
}

var l = readline().split(' ').map(Number);
var x = f(l[0], l[1], l[2]), y = f(l[0], l[2], l[1]);
print(x > y ? x : y);

var arr = readline().split(' ')
var max = -1;

for (var i = 1; i < arr[0]; i++) max = Math.max(max, Math.min(arr[1]/i, arr[2]/(arr[0]-i)));

print(max);

const
    conditions = readline().split(' '),
    platesCount = +conditions[0],
    cakes_1 = +conditions[1],
    cakes_2 = +conditions[2];

var
    plates = [],
    pieces = 0,
    minPieces = Math.floor((cakes_1 + cakes_2) / platesCount);

while (minPieces > cakes_1 || minPieces > cakes_2) {
    minPieces--;
}

if (minPieces === 1) {
    print(minPieces);
} else {
    var
        tmpCakes_1 = Math.min(cakes_1, cakes_2),
        tmpCakes_2 = Math.max(cakes_1, cakes_2);
    for (var i = 0; i < platesCount; i++) {
        if (tmpCakes_1) {
            if (tmpCakes_1 >= minPieces) {
                plates.push(minPieces)
                tmpCakes_1 -= minPieces;
            } else {
                plates.push(tmpCakes_1);
                tmpCakes_1 = 0;
            }
        } else {
            if (tmpCakes_2 >= minPieces) {
                if (i === platesCount - 1) {
                    plates.push(tmpCakes_2);
                } else {
                    plates.push(minPieces)
                    tmpCakes_2 -= minPieces;
                }
            } else {
                plates.push(tmpCakes_2);
            }
        }
    }
    pieces = plates.reduce((a, b) => {return Math.min(a, b)})
}
print(pieces)

const
    conditions = readline().split(' '),
    platesCount = +conditions[0],
    cakes_1 = +conditions[1],
    cakes_2 = +conditions[2];

var
    plates = [],
    pieces = 0,
    minPieces = Math.floor((cakes_1 + cakes_2) / platesCount);

while (minPieces > cakes_1 || minPieces > cakes_2) {
    minPieces--;
}

function putCakes() {
    var
        plates = [],
        tmpCakes_1 = Math.min(cakes_1, cakes_2),
        tmpCakes_2 = Math.max(cakes_1, cakes_2);
    for (var i = 0; i < platesCount; i++) {
        if (tmpCakes_1) {
            if (tmpCakes_1 >= minPieces) {
                plates.push(minPieces)
                tmpCakes_1 -= minPieces;
            } else {
                plates.push(tmpCakes_1);
                tmpCakes_1 = 0;
            }
        } else {
            if (tmpCakes_2 >= minPieces) {
                if (i === platesCount - 1) {
                    plates.push(tmpCakes_2);
                } else {
                    plates.push(minPieces)
                    tmpCakes_2 -= minPieces;
                }
            } else {
                plates.push(tmpCakes_2);
            }
        }
    }
    pieces = plates.reduce((a, b) => {return Math.min(a, b)})
    if ((pieces + 1) < minPieces) {
        minPieces --;
        putCakes();
    } else {
        print(pieces)
    }
}

if (minPieces === 1) {
    print(minPieces);
} else {
    putCakes();
}

const
    conditions = readline().split(' '),
    platesCount = +conditions[0],
    cakes_1 = +conditions[1],
    cakes_2 = +conditions[2];

var
    plates = [],
    pieces = 0,
    minPieces = Math.floor((cakes_1 + cakes_2) / platesCount);

while (minPieces > cakes_1 || minPieces > cakes_2) {
    minPieces--;
}

function putCakes() {
    var
        plates = [],
        tmpCakes_1 = Math.min(cakes_1, cakes_2),
        tmpCakes_2 = Math.max(cakes_1, cakes_2);
    for (var i = 0; i < platesCount; i++) {
        if (tmpCakes_1) {
            if (tmpCakes_1 >= minPieces) {
                plates.push(minPieces)
                tmpCakes_1 -= minPieces;
            } else {
                plates.push(tmpCakes_1);
                tmpCakes_1 = 0;
            }
        } else {
            if (tmpCakes_2 >= minPieces) {
                if (i === platesCount - 1) {
                    plates.push(tmpCakes_2);
                } else {
                    plates.push(minPieces)
                    tmpCakes_2 -= minPieces;
                }
            } else {
                plates.push(tmpCakes_2);
            }
        }
    }

    pieces = plates.reduce((a, b) => {return Math.min(a, b)})
    if (pieces < minPieces) {
        minPieces --;
        putCakes();
    } else {
        print(minPieces);
    }
}

if (minPieces === 1) {
    print(minPieces);
} else {
    putCakes();

}

const
    conditions = readline().split(' '),
    platesCount = +conditions[0],
    cakes_1 = +conditions[1],
    cakes_2 = +conditions[2];

var
    plates = [],
    pieces = 0,
    minPieces = Math.floor((cakes_1 + cakes_2) / platesCount);

while (minPieces > cakes_1 || minPieces > cakes_2) {
    minPieces--;
}

if (minPieces === 1) {
    print(minPieces);
} else {
    var
        tmpCakes_1 = Math.min(cakes_1, cakes_2),
        tmpCakes_2 = Math.max(cakes_1, cakes_2);
    for (var i = 0; i < platesCount; i++) {
        if (tmpCakes_1) {
            if (tmpCakes_1 >= minPieces) {
                plates.push(minPieces)
                tmpCakes_1 -= minPieces;
            } else {
                plates.push(tmpCakes_1);
                tmpCakes_1 = 0;
            }
        } else {
            if (tmpCakes_2 >= minPieces) {
                if (i === platesCount - 1) {
                    plates.push(tmpCakes_2);
                } else {
                    plates.push(minPieces)
                    tmpCakes_2 -= minPieces;
                }
            } else {
                plates.push(tmpCakes_2);
            }
        }
    }
    pieces = plates.reduce((a, b) => {return Math.min(a, b)})
    print(pieces)
}

function main() {
  var data = readline().split(" ");
  var plates = data[0];
  var firstCake = data[1];
  var secondCake = data[2];

  var maxPieces = Math.floor((firstCake + secondCake) / plates);
  if (
    firstCake === 1 ||
    secondCake === 1 ||
    firstCake + secondCake < 2 * plates
  )
    maxPieces = 1;
  else {
    while (
      Math.floor(firstCake / maxPieces) + Math.floor(secondCake / maxPieces) <
      plates
    ) {
      maxPieces--;
    }
  }
  print(maxPieces);
}

main();

var inputData = readline().split(' ');
var guests = parseInt(inputData[0]);
var a = parseInt(inputData[1]);
var b = parseInt(inputData[2]);
var aPart = Math.round(guests / (a + b) * a);
var bPart = Math.round(guests / (a + b) * b);
    if (aPart < 1) {
        aPart++;
        bPart--;
    } else if (bPart < 1) {
        bPart++;
        aPart--;
    }
if (a < b) {
    print(Math.floor(a / aPart));
} else {
    print(Math.floor(b / bPart));
}

var inputData = readline().split(' ');
var guests = parseInt(inputData[0]);
var a = parseInt(inputData[1]);
var b = parseInt(inputData[2]);
var index = guests / (a + b);
var aPart = index * a;
var bPart = index * b;
if (aPart < bPart) {
    aPart = Math.ceil(aPart);
    bPart = Math.floor(bPart);
    print(Math.floor(a / aPart));
} else {
    bPart = Math.ceil(bPart);
    aPart = Math.floor(aPart);
    print(Math.floor(b / bPart));
}

var inputData = readline().split(' ');
var guests = parseInt(inputData[0]);
var a = parseInt(inputData[1]);
var b = parseInt(inputData[2]);
var aPart = Math.round(guests / (a + b) * a);
var bPart = Math.round(guests / (a + b) * b);
    if (aPart < 1) {
        aPart++;
        bPart--;
    } else if (bPart < 1) {
        bPart++;
        aPart--;
    }
var minAPart = Math.floor(a / aPart);
var minBPart = Math.floor(b / bPart);
print(minAPart < minBPart ? minAPart : minBPart);

var firstLine = readline();
print('\n');

print(tort(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      const curr = Math.min(Math.floor(x / i), Math.floor(y / (k - i)));
      if (curr > maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

var firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  var allCake = firstCake + secondCake;
  var procentFirst = firstCake / allCake * 100 ;
  var plateForFirst = Math.round(plate * procentFirst / 100);
  var plateForSecond = plate - plateForFirst;

  if (plateForFirst ===  plate && secondCake > 0) {
    --plateForFirst;
    ++plateForSecond;
  } else if (plateForSecond ===  plate && firstCake > 0) {
    ++plateForFirst;
    --plateForSecond;
  }

  var pathOfFirst = Math.floor(firstCake / plateForFirst);
  var pathOfSecond = Math.floor(secondCake / plateForSecond);
  if (pathOfFirst < pathOfSecond) {
    return pathOfFirst;
  }
  return  pathOfSecond;
}

var firstLine = readline();
print('\n');

print(tort(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

// console.log(tort(100, 100, 100));
function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      const curr = Math.min(Math.round(x / i), Math.round(y / (k - i)));
      if (curr >= maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

var firstLine = readline();
// print('\n');

var args = firstLine.split(' ');

print(tort(...args));

function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      const curr = Math.min(Math.floor(x / i), Math.floor(y / (k - i)));
      if (curr > maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

var firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  var rezult = 0;
  var allCake = firstCake + secondCake;
  var procentFirst = firstCake / allCake * 100 ;
  var plateForFirst = Math.round(plate * procentFirst / 100);
  var plateForSecond = plate - plateForFirst;

  if (plateForFirst ===  plate && secondCake > 0) {
    --plateForFirst;
    ++plateForSecond;
  } else if (plateForSecond ===  plate && firstCake > 0) {
    ++plateForFirst;
    --plateForSecond;
  }

  var pathOfFirst = Math.floor(firstCake / plateForFirst);
  var pathOfSecond = Math.floor(secondCake / plateForSecond);
  if (pathOfFirst < pathOfSecond) {
    rezult = pathOfFirst;
  } else {
    rezult = pathOfSecond;
  }

  return rezult;
}

var firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  var allCake = firstCake + secondCake;
  var procentFirst = firstCake / allCake * 100 ;
  var plateForFirst = Math.floor(plate * procentFirst / 100) === 0 ? 1 : Math.floor(plate * procentFirst / 100);
  var plateForSecond = plate - plateForFirst;
  var pathOfFirst = Math.floor(firstCake / plateForFirst);
  var pathOfSecond = Math.floor(secondCake / plateForSecond);

  if (pathOfFirst < pathOfSecond) {
    return pathOfFirst;
  }
  return  pathOfSecond;
}

var firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  const allCake = firstCake + secondCake;
  const procentFirst = firstCake / allCake * 100 ;
  const plateForFirst = Math.round(plate * procentFirst / 100);
  const plateForSecond = plate - plateForFirst;
  const pathOfFirst = Math.floor(firstCake / plateForFirst);
  const pathOfSecond = Math.floor(secondCake / plateForFirst);

  return pathOfFirst < pathOfSecond ? pathOfFirst : pathOfSecond;
}

var firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  var allCake = firstCake + secondCake;
  var procentFirst = firstCake / allCake * 100 ;
  var plateForFirst = Math.round(plate * procentFirst / 100);
  var plateForSecond = plate - plateForFirst;
  var pathOfFirst = Math.floor(firstCake / plateForFirst);
  var pathOfSecond = Math.floor(secondCake / plateForFirst);

  return pathOfFirst < pathOfSecond ? pathOfFirst : pathOfSecond;
}

const firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  const allCake = firstCake + secondCake;
  const procentFirst = firstCake / allCake * 100 ;
  const plateForFirst = Math.round(plate * procentFirst / 100);
  const plateForSecond = plate - plateForFirst;
  const pathOfFirst = Math.floor(firstCake / plateForFirst);
  const pathOfSecond = Math.floor(secondCake / plateForFirst);
  if (pathOfFirst < pathOfSecond) {
    return pathOfFirst;
  }
  return  pathOfSecond;
}

var firstLine = readline();
print('\n');

print(tort(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

// console.log(tort(100, 100, 100));
function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      const curr = Math.min(Math.round(x / i), Math.round(y / (k - i)));
      if (curr > maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

const firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  const allCake = firstCake + secondCake;
  const procentFirst = firstCake / allCake * 100 ;
  const plateForFirst = Math.round(plate * procentFirst / 100);
  const plateForSecond = plate - plateForFirst;
  const pathOfFirst = Math.floor(firstCake / plateForFirst);
  const pathOfSecond = Math.floor(secondCake / plateForFirst);

  return pathOfFirst < pathOfSecond ? pathOfFirst : pathOfSecond;
}

var firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  var allCake = firstCake + secondCake;
  var procentFirst = firstCake / allCake * 100 ;
  var plateForFirst = Math.round(plate * procentFirst / 100);
  var plateForSecond = plate - plateForFirst;
  var pathOfFirst = Math.floor(firstCake / plateForFirst);
  var pathOfSecond = Math.floor(secondCake / plateForSecond);

  if (pathOfFirst < pathOfSecond) {
    return pathOfFirst;
  }
  return  pathOfSecond;
}

var firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  var rezult = 0;
  var allCake = firstCake + secondCake;
  var procentFirst = firstCake / allCake * 100 ;
  var plateForFirst = Math.round(plate * procentFirst / 100);
  var plateForSecond = plate - plateForFirst;

  if (plateForFirst ===  plate && secondCake > 0) {
    --plateForFirst;
    ++plateForSecond;
  } else if (plateForSecond ===  plate && firstCake > 0) {
    ++plateForFirst;
    --plateForSecond;
  }

  pathOfFirst = Math.floor(firstCake / plateForFirst);
  pathOfSecond = Math.floor(secondCake / plateForSecond);
  if (pathOfFirst < pathOfSecond) {
    rezult <= pathOfFirst ? pathOfFirst : rezult;;
  } else {
    rezult <= pathOfSecond ? pathOfSecond : rezult;;
  }

  --plateForFirst;
  ++plateForSecond;

  var pathOfFirst = Math.floor(firstCake / plateForFirst);
  var pathOfSecond = Math.floor(secondCake / plateForSecond);
  if (pathOfFirst < pathOfSecond) {
    rezult <= pathOfFirst ? pathOfFirst : rezult;;
  } else {
    rezult <= pathOfSecond ? pathOfSecond : rezult;;
  }

  return rezult;
}

var firstLine = readline();
print('\n');

print(tort(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      const curr = Math.min(Math.round(x / i), Math.round(y / (k - i)));
      if (curr >= maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

var firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  debugger;
  var allCake = firstCake + secondCake;
  var procentFirst = firstCake / allCake * 100 ;
  var plateForFirst = Math.floor(plate * procentFirst / 100);
  var plateForSecond = plate - plateForFirst;
  var pathOfFirst = Math.floor(firstCake / plateForFirst);
  var pathOfSecond = Math.floor(secondCake / plateForSecond);

  if (pathOfFirst < pathOfSecond) {
    return pathOfFirst;
  }
  return  pathOfSecond;
}

var firstLine = readline();
print(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]);

print(tort(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      const curr = Math.min(Math.round(x / i), Math.round(y / (k - i)));
      if (curr >= maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

var firstLine = readline();
print('\n');

var args = firstLine.split(' ');

print(tort(args[0], args[111], args[2]));

function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      var curr = Math.min(Math.floor(x / i), Math.floor(y / (k - i)));
      if (curr > maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

var firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  var allCake = firstCake + secondCake;
  var procentFirst = firstCake / allCake * 100 ;
  var plateForFirst = Math.round(plate * procentFirst / 100);
  var plateForSecond = plate - plateForFirst;
  var pathOfFirst = Math.floor(firstCake / plateForFirst);
  var pathOfSecond = Math.floor(secondCake / plateForFirst);

  if (pathOfFirst < pathOfSecond) {
    return pathOfFirst;
  }
  return  pathOfSecond;
}

var firstLine = readline();
print('\n');

print(tort(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function tort(k, x, y) {
  var maxMin = 0;

  for (var i = 1; i < k; i++) {
      const curr = Math.min(Math.round(x / i), Math.round(y / (k - i)));
      if (curr > maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}

const firstLine = readline();
print('\n');

print(getRezult(+firstLine.split(' ')[0], +firstLine.split(' ')[1], firstLine.split(' ')[2]))

function getRezult (plate, firstCake, secondCake) {
  const allCake = firstCake + secondCake;
  const procentFirst = firstCake / allCake * 100 ;
  const plateForFirst = Math.round(plate * procentFirst / 100);
  const plateForSecond = plate - plateForFirst;
  const pathOfFirst = Math.floor(firstCake / plateForFirst);
  const pathOfSecond = Math.floor(secondCake / plateForFirst);

  if (pathOfFirst < pathOfSecond) {
    return 5;
  }
  return  20;
}

var inputData = readline().split(' ').map(Number);//prompt("enter 3 argymentf").split(' ').map(Number);
var bigestDigit = -1;
var tarelkiTortu = inputData[0], kyskiTorta1 = inputData[1], kyskiTorta2 = inputData[2];

    for( var i = 1; i < tarelkiTortu; ++i){
        var calcTort1 = Math.round(kyskiTorta1/i);
        var calcTort2 = Math.round(kyskiTorta2/(tarelkiTortu - i));
    if(calcTort1 && calcTort2){
        var smallerDigit = Math.min(calcTort1, calcTort2);
       bigestDigit = Math.max(smallerDigit, bigestDigit);
    }
}

print(bigestDigit);//alert("bigestDigit");

var inputData = readline().split(' ').map(Number);//prompt("enter 3 argymentf").split(' ').map(Number);
var bigestDigit = 0;
var tarelkiTortu = inputData[0], kyskiTorta1 = inputData[1], kyskiTorta2 = inputData[2];

function calculate(){
    for( var i = 1; i < tarelkiTortu; i++){
        var calcTort1 = Math.round(this.kyskiTorta1/i);
        var calcTort2 = Math.round(this.kyskiTorta2/(this.tarelkiTortu - i));
    if(calcTort1 && calcTort2){
        var smallerDigit = Math.min(calcTort1, calcTort2);
       this.bigestDigit = Math.max(smallerDigit, bigestDigit);
    }
}
}
print(bigestDigit);//alert("bigestDigit");

var inputData = readline().split(' ').map(Number);//prompt("enter 3 argymentf").split(' ').map(Number);
var bigestDigit = 0;
var tarelkiTortu = inputData[0], kyskiTorta1 = inputData[1], kyskiTorta2 = inputData[2];

    for( var i = 1; i < tarelkiTortu; ++i){
        var calcTort1 = Math.round(this.kyskiTorta1/i);
        var calcTort2 = Math.round(this.kyskiTorta2/(this.tarelkiTortu - i));
    if(calcTort1 && calcTort2){
        var smallerDigit = Math.min(calcTort1, calcTort2);
       this.bigestDigit = Math.max(smallerDigit, bigestDigit);
    }
}

print(bigestDigit);//alert("bigestDigit");

var inputData = readline().split(' ').map(Number);//prompt("enter 3 argymentf").split(' ').map(Number);
var bigestDigit = 0;
var tarelkiTortu = inputData[0], kyskiTorta1 = inputData[1], kyskiTorta2 = inputData[2];

    for( var i = 1; i < tarelkiTortu; i++){
        var calcTort1 = Math.round(this.kyskiTorta1/i);
        var calcTort2 = Math.round(this.kyskiTorta2/(this.tarelkiTortu - i));
    if(calcTort1 && calcTort2){
        var smallerDigit = Math.min(calcTort1, calcTort2);
       this.bigestDigit = Math.max(smallerDigit, bigestDigit);
    }
}

print(bigestDigit);//alert("bigestDigit");

_=readline().split(' ').map(Number)
n=_[0],a=_[1],b=_[2]
x=1000000000
for (var i=1;i<n-1;++i) {
  var ai=Math.trunc(a/i),
    bi=Math.trunc(b/(n-i))
  if (ai && bi)
    x=Math.min(x, ai, bi)
}
print(x)


process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
	inputString += inputStdin;
});

process.stdin.on('end', (_) => {
	inputString = inputString.trim().split('\n').map((string) => {
		return string.trim();
	});

	main();
});

function readline() {
	return inputString[currentLine++];
}

function main() {
	let n = +readline();
	let a = [];
	while (n--) {
		let m = +readline();
		a.push(m);
	}
	let flag = calc(a, 0);
	if (flag == 0) console.log('NO');
	else console.log('YES');
}

calc = (a, sum) => {
	if (a.length == 0) {
		if (sum % 360 == 0) return 1;
		else return 0;
	} else {
		return calc(a.slice(1), sum + a[0]) + calc(a.slice(1), sum - a[0]);
	}
};

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL) ;/*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length).filter(l => l).map(l => parseInt(l));

    if ((arr.reduce((a, v) => a + v, 0) % 360) === 0) {
    	console.log("YES");
    	return;
    }

   	function subseqs(arr, k) {
			const n = arr.length;
			const res = [];
			let j = 0;

			for (let mask = 0; mask < (1 << n); mask++) {
				let num = 0;

				for (let i = 0; i < n; i++) {
					if (mask & (1 << i)) {
						num++;
					}
				}

				if (num === k) {
					res[j] = [0, 0];

					for (let i = 0; i < n; i++) {
						if (mask & (1 << i)) {
							res[j][0] = (res[j][0] + arr[i]) % 360;
						} else {
							res[j][1] = (res[j][1] + arr[i]) % 360;
						}
					}

					j++;
				}
			}

			return res;
		}

	for (let i = 1; i < arr.length / 2 + 1; i++) {
		for (const ss of subseqs(arr, i)) {
			if (ss[0] === ss[1]) {
				console.log("YES");
				return;
			}
		}
	}

	console.log("NO");
});

// const lines = `15
// 168
// 168
// 168
// 168
// 168
// 168
// 168
// 168
// 168
// 168
// 168
// 168
// 168
// 168
// 168`.split('\n');
//
// const k = lines[0];
// const arr = lines.slice(1, lines.length).filter(l => l).map(l => parseInt(l));
//
// if ((arr.reduce((a, v) => a + v, 0) % 360) === 0) {
// 	console.log("YES");
// 	proccess.exit(0);
// }
//
// function subseqs(arr, k) {
// 	const n = arr.length;
// 	const res = [];
// 	let j = 0;
//
// 	for (let mask = 0; mask < (1 << n); mask++) {
// 		let num = 0;
//
// 		for (let i = 0; i < n; i++) {
// 			if (mask & (1 << i)) {
// 				num++;
// 			}
// 		}
//
// 		if (num === k) {
// 			res[j] = [0, 0];
//
// 			for (let i = 0; i < n; i++) {
// 				if (mask & (1 << i)) {
// 					res[j][0] = (res[j][0] + arr[i]) % 360;
// 				} else {
// 					res[j][1] = (res[j][1] + arr[i]) % 360;
// 				}
// 			}
//
// 			j++;
// 		}
// 	}
//
// 	return res;
// }
//
// for (let i = 1; i < arr.length; i++) {
// 	for (const ss of subseqs(arr, i)) {
// 		if (ss[0] === ss[1]) {
// 			console.log("YES");
// 			proccess.exit(0);
// 		}
// 	}
// }
//
// console.log("NO");
//

var n = +readline();

var mas = [];
var i = 0;

while(i < n) {
	mas[i] = +readline();
	i++;
}
i = 0;
var max = Math.pow(2, n);
var result = 'NO';

while(i <= max) {
	var rrr = summ(convert(i));
	if(rrr %360 === 0) {
		result = 'YES';
		break;
    }
	i++;
}

print(result);

function convert(input) {
	var s = input.toString(2);
	while(n > s.length) { s = "0"+s; }
	return s;
}

function summ(st) {
	var x = 0;
	var p = 0;
	while(p < n) {
		x += (mas[p] * (+st[p] ? 1 : -1));
		p++;
    }
	return x;
}

const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  lines.push(Number(line));
});

const processAngles = (n, angles) => {
  for (let i = 0; i < 2 ** (n - 1); i += 1) {
    const bitbask = i.toString(2).padStart(angles.length, '0');
    const rotation = angles.reduce((acc, angle, idx) => {
      if (bitbask[idx] === '0') {
        return acc + angle;
      }

      return acc - angle;
    }, 0);

    if (rotation % 360 === 0) {
      return 'YES';
    }
  }

  return 'NO';
};

readline.on('close', () => {
  const [n, ...angles] = lines;

  console.log(processAngles(n, angles));
});

function padStart(value,targetLength,padString) {
    targetLength = targetLength>>0;
    padString = String(padString || ' ');
    if (value.length > targetLength) {
        return value;
    }
    else {
        targetLength = targetLength-value.length;
        if (targetLength > padString.length) {
            padString += padString.repeat(targetLength/padString.length);
        }
        return padString.slice(0,targetLength) +value;
    }
}

function main() {
    var n = +readline();
    var a = [];

    for(var i = 0; i < n; i++) {
        a.push(+readline());
    }

    var sum = a.reduce((sum,i) => sum +i, 0);

    if(sum % 360 === 0) {
        print('YES');
        return;
    }

    if(sum % 2 != 0) {
        print('NO');
        return;
    }

    var k = parseInt(padStart('', n , '1'), 2);
    for(var i = 1; i < k; i++) {
        var dv = padStart(i.toString(2), n, '0');
        s = a.reduce(function(res, item, index) {
            return res + (dv[index] == 1 ? '+': '-') + item;
        }, '');
        if(eval(s) % 360 === 0) {
            print ('YES');
            return;
        }
    }
    print('NO');
}
main();

function padStart(value,targetLength,padString) {
    targetLength = targetLength>>0;
    padString = String(padString || ' ');
    if (value.length > targetLength) {
        return value;
    }
    else {
        targetLength = targetLength-value.length;
        if (targetLength > padString.length) {
            padString += padString.repeat(targetLength/padString.length);
        }
        return padString.slice(0,targetLength) +value;
    }
}

function main() {
    var n = +readline();
    var a = [];

    for(var i = 0; i < n; i++) {
        a.push(+readline());
    }

    var sum = a.reduce((sum,i) => sum +i, 0);

    if(sum % 360 === 0) {
        print('YES');
        return;
    }

    if(sum % 2 != 0) {
        print('NO');
        return;
    }

    var k = parseInt(padStart('', n , '1'), 2);
    for(var i = 1; i < k; i++) {
        var dv = padStart(i.toString(2), n, '0');
        s = a.reduce(function(res, item, index) {
            return res + (dv[index] == 1 ? '+': '-') + item;
        }, '');
        if(eval(s) === 0) {
            print ('YES');
            return;
        }
    }
    print('NO');
}
main();

var arr = [];

var n = +readline();
var i = 0;
var sum = 0;

while(i < n) {
	arr[i] = +readline();
	sum += arr[i];
	i++;
}
if(sum == 360) {
	arr = sortt(arr);

	while(n != 1) {
		arr[i-2] = arr[i-1] - arr[i-2];
		arr.pop();
		arr = sortt(arr);
		n = arr.length;
	}

	if(arr[0] === 0) { print('YES'); }
	else { print('NO'); }

	function sortt(arr) {
		return arr.sort(function(a, b) { return a - b; });
	}
} else {
	print('YES');
}

var n = +readline();

var mas = [];
var i = 0;

while(i < n) {
	mas[i] = +readline();
	i++;
}
i = 0;
var max = Math.pow(2, n);
var result = 'NO';

while(i <= max) {
	var rrr = summ(convert(i));
	if(rrr == 360 || rrr === 0) {
		result = 'YES';
		break;
    }
	i++;
}

print(result);

function convert(input) {
	var s = input.toString(2);
	while(n > s.length) { s = "0"+s; }
	return s;
}

function summ(st) {
	var x = 0;
	var p = 0;
	while(p < n) {
		x += (mas[p] * (+st[p] ? 1 : -1));
		p++;
    }
	return x;
}

var arr = [];

var n = +readline();
var i = 0;
var sum = 0;

while(i < n) {
	arr[i] = +readline();
	sum += arr[i];
	i++;
}
if(sum != 360) {
	arr = sortt(arr);

	while(n != 1) {
		arr[n-2] = arr[n-1] - arr[n-2];
		arr.pop();
		arr = sortt(arr);
		n = arr.length;
	}

	if(arr[0] === 0) { print('YES'); }
	else { print('NO'); }

	function sortt(ar) {
		return ar.sort(function(a, b) { return a - b; });
	}
} else {
	print('YES');
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1);

    console.log(arr);

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length; i++) {
	  subseqs(arr, i).map(ss => console.log(ss[0] == ss[1] ? "YES" : "NO"));
	}
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length - 1);

    console.log(arr);

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length; i++) {
	  subseqs(arr, i).map(ss => console.log(ss[0] == ss[1] ? "YES" : "NO"));
	}
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length).map(l => l).map(l => parseInt(l));

    if (arr.reduce((a, v) => a + v, 0) === 360) {
    	console.log("YES");
    	return;
    }

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length; i++) {
		for (const ss of subseqs(arr, i)) {
			if (ss[0] === ss[1]) {
				console.log("YES");
				return;
			}
		}
	}

	console.log("NO");
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length - 1).map(l => parseInt(l));

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length; i++) {
		for (const ss of subseqs(arr, i)) {
			if (ss[0] === ss[1]) {
				console.log("YES");
				return;
			}
		}
	}

	console.log("NO");
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1);

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length; i++) {
	  subseqs(arr, i).map(ss => console.log(ss[0] == ss[1] ? "YES" : "NO"));
	}
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length - 1).map(l => parseInt(l));

    console.log(arr);

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length; i++) {
	  subseqs(arr, i).map(ss => console.log(ss[0] == ss[1] ? "YES" : "NO"));
	}
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length).filter(l => l).map(l => parseInt(l));

    if (arr.reduce((a, v) => a + v, 0) === 360) {
    	console.log("YES");
    	return;
    }

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length / 2; i++) {
		for (const ss of subseqs(arr, i)) {
			if (ss[0] === ss[1]) {
				console.log("YES");
				return;
			}
		}
	}

	console.log("NO");
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length - 1).map(l => parseInt(l));

    console.log(arr);

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length; i++) {
		for (const ss of subseqs(arr, i)) {
			if (ss[0] === ss[1]) {
				console.log("YES");
				return;
			}
		}
	}

	console.log("NO");
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length - 1).map(l => parseInt(l));

    if (arr.reduce((a, v) => a + v, 0) === 360) {
    	console.log("YES");
    	return;
    }

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length; i++) {
		for (const ss of subseqs(arr, i)) {
			if (ss[0] === ss[1]) {
				console.log("YES");
				return;
			}
		}
	}

	console.log("NO");
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL) ;/*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length).filter(l => l).map(l => parseInt(l));

    if (arr.reduce((a, v) => a + v, 0) === 360) {
    	console.log("YES");
    	return;
    }

   	function subseqs(arr, k) {
			const n = arr.length;
			const res = [];
			let j = 0;

			for (let mask = 0; mask < (1 << n); mask++) {
				let num = 0;

				for (let i = 0; i < n; i++) {
					if (mask & (1 << i)) {
						num++;
					}
				}

				if (num === k) {
					res[j] = [0, 0];

					for (let i = 0; i < n; i++) {
						if (mask & (1 << i)) {
							res[j][0] = (res[j][0] + arr[i]) % 360;
						} else {
							res[j][1] = (res[j][1] + arr[i]) % 360;
						}
					}

					j++;
				}
			}

			return res;
		}

	for (let i = 1; i < arr.length / 2 + 1; i++) {
		for (const ss of subseqs(arr, i)) {
			if (ss[0] === ss[1]) {
				console.log("YES");
				return;
			}
		}
	}

	console.log("NO");
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length).filter(l => l).map(l => parseInt(l));

    if (arr.reduce((a, v) => a + v, 0) === 360) {
    	console.log("YES");
    	return;
    }

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length / 2 + 1; i++) {
		for (const ss of subseqs(arr, i)) {
			if (ss[0] === ss[1]) {
				console.log("YES");
				return;
			}
		}
	}

	console.log("NO");
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    const k = lines[0];
    const arr = lines.slice(1, lines.length).filter(l => l).map(l => parseInt(l));

    if (arr.reduce((a, v) => a + v, 0) === 360) {
    	console.log("YES");
    	return;
    }

   	function subseqs(arr, k) {
	  const n = arr.length;
	  const res = [];
	  let j = 0;

	  for (let mask = 0; mask < (1 << n); mask++) {
	    let num = 0;

	    for (let i = 0; i < n; i++) {
	      if (mask & (1 << i)) {
	        num++;
	      }
	    }

	    if (num === k) {
	      res[j] = [0, 0]

	      for (let i = 0; i < n; i++) {
	        if (mask & (1 << i)) {
	          res[j][0] += arr[i]
	        } else {
	          res[j][1] += arr[i];
	        }
	      }

	      j++;
	    }
	  }

	  return res;
	}

	for (let i = 1; i < arr.length; i++) {
		for (const ss of subseqs(arr, i)) {
			if (ss[0] === ss[1]) {
				console.log("YES");
				return;
			}
		}
	}

	console.log("NO");
});

const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  lines.push(Number(line));
});

const processAngles = (n, angles) => {
  for (let i = 0; i < 2 ** (n - 1); i += 1) {
    const bitbask = i.toString(2).padStart(angles.length, '0');
    const rotation = angles.reduce((acc, angle, idx) => {
      if (bitbask[idx] === '0') {
        return acc + angle;
      }

      return acc - angle;
    }, 0);

    if (rotation === 0 || rotation === 360) {
      return 'YES';
    }
  }

  return 'NO';
};

readline.on('close', () => {
  const [n, ...angles] = lines;

  console.log(processAngles(n, angles));
});


var n=readline();
//print(n);
var str=readline();
//print(str);
var cnt=0,mn=0;
for(var i=0;i<n;i++)
{
	if(str[i]=='-')
	{
		cnt--;
	}
	else
	{
		cnt++;
	}
	if(cnt<mn)
	{
		mn=cnt;
	}
}
mn=-mn;
//print(mn);
for(var i=0;i<n;i++)
{
	if(str[i]=='-')
	{
		mn--;
	}
	else
	{
		mn++;
	}

}
print(mn);

const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});

let c = 0;

rl.on("line", (str) => {
  if (c === 0) {
    c++;
    return;
  }

  let ans = 0;

  for (let i = 0; i < str.length; i++) {
    if (str[i] === "+") {
      ans++;
    } else {
      ans = Math.max(0, --ans);
    }
  }

  console.log(ans);
  c++;
});

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.number();
    var s = readline();

    var res = 0;
    for(var i = 0; i < n; i++) {
        if(s[i] === '-'){
           res--;
        }
        else {
           res++;
        }

        if(res < 0) {
            res = 0;
        }
    }
    print(res);
}());

let [n, s] = require('fs')
    .readFileSync(0, 'ascii')
    .split('\n')
    .filter(line => !/^\s*$/.test(line));

let min = 0;
let sum = 0;
for (const c of s) {
    if (c == '+') {
        sum++;
    } else if (c == '-') {
        sum--;
        if (sum < min)
            min = sum;
    }
}

console.log(sum - min);

var readline = require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
var STATE = 1;
var n;
rl.on('line', function (input) {
  switch (STATE) {
    case 1:
      n = parseInt(input, 10);
      // console.log(STATE + ':', n);
      STATE = 2;
      break;
    case 2:
      // console.log(STATE + ':', input);
      var init = 0;
      var added = 0;
      for (var i = 0, len = input.length; i < len; i++) {
        var char = input[i];
        switch (char) {
          case '+':
            added++;
            break;
          case '-':
            if (added) {
              added--;
            } else {
              init++;
            }
            break;
          default:
            throw new Error('Error case');
        }
      }
      // console.log(init, added);
      console.log(added);
      STATE = 1;
      break;
    default:
      // code
  }
}).on('close', function() {
  process.exit(0);
});