/**
Polycarp has just invented a new binary protocol for data transmission. He is encoding positive integer decimal number to binary string using following algorithm:

Each digit is represented with number of '1' characters equal to the value of that digit (for 0 it is zero ones).
Digits are written one by one in order corresponding to number and separated by single '0' character.
Though Polycarp learnt how to encode the numbers, he has no idea how to decode them back. Help him calculate the decoded number.

Input
The first line contains one integer number n (1 ≤ n ≤ 89) — length of the string s.

The second line contains string s — sequence of '0' and '1' characters, number in its encoded format. It is guaranteed that the number corresponding to the string is positive and doesn't exceed 109. The string always starts with '1'.

Output
Print the decoded number.

Examples
input
3
111
output
3
input
9
110011101
output
2031

 */

let inputString = '';

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

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

    let lengthOfString = Number(inputString[0]);
    let string = inputString[1];

    solution(lengthOfString, string);

});

function solution(lengthOfString, string) {

    let onesCount = 0;
    let zeorCount = '';
    let digit = [];

    for (let index = 0; index < lengthOfString; index++) {

        if (string[index] == '1') {

            onesCount++;

            if (zeorCount.length > 1)
                digit.push(zeorCount.substring(0, zeorCount.length - 1));

            zeorCount = '';
        }

        if (string[index] == '0') {

            zeorCount += '0';

            if (onesCount)
                digit.push(onesCount.toString());

            onesCount = 0;
        }
    }

    if (onesCount)
        digit.push(onesCount.toString());

    if (zeorCount.length )
        digit.push(zeorCount);

    console.log(digit.join(""));

}


const input = [];

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

RL.on('line', (line) => {
    input.push(line);
});

RL.on('close', () => {
  const param = input[0];
  const pattern = "qwertyuiopasdfghjkl;zxcvbnm,./";

  const answer = [];
  for (let i = 0; i < input[1].length; i += 1) {
    let k = pattern.indexOf(input[1][i]);

    if (param === 'R') {
      answer.push(pattern.charAt(k-1));
    } else {
      answer.push(pattern.charAt(k+1));
    }
  }
  console.log(answer.join(''))
});


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

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  const str1 = input[0], str2 = input[1];

  if (str1.length !== str2.length) {
    console.log('NO'); return;
  }

  let j = str1.length-1;
  for (let i = 0; i < str1.length; i += 1, j -= 1 ) {
    if (str1[i] !== str2[j]) {
      console.log('NO'); return;
    }
  }

  console.log('YES');
});


'use strict';

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 readAsInt(){
  return parseInt(readline());
}

function readAsIntList(){
  return readline().split(' ').filter(i => i).map(i => parseInt(i));
}

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  let name = readline();
  console.log([...new Set(name.split(''))].length % 2 === 0 ? 'CHAT WITH HER!' : 'IGNORE HIM!' );
}


let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

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

function isPrime(x) {
	let s = Math.sqrt(x);
	let i = 2;
	while (i <= s) {
		if (x % i === 0) {
			return false;
		}
		i++;
	}
	return true;
}

function main() {
	let s1 = readLine().split(''),
		s2 = readLine().split(''),
		res = s1.map((d, i) => (d !== s2[i] ? '1' : '0'));
	console.log(res.join(''));
}


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 ones = 0;
  let zeros = 0;

  for (let i = 0; i < str.length; i++) {
    if (str[i] === '1') {
      ones++;
    }
    else {
      zeros++;
    }
  }

  if (ones === 0) {
    console.log(0);
  }
  else {
    console.log(`1${'0'.repeat(zeros)}`);
  }

  c++;
});


let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader ();

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;

	// To read Number from console
	let noOfTestCases = inputReader.readNumber();

	if(noOfTestCases%2==0 && noOfTestCases!==2){
	    console.log('YES');
	}
	else
	    console.log("NO");
	// console.log(noOfTestCases,typeof noOfTestCases);
	// while(noOfTestCases--){
	//     // To read generic array separated by space
	//     let tmp = inputReader.readArray();
	//     console.log(tmp, typeof tmp);

	//     // To read boolean value i.e. 'true' or 'false' (It's case insensitive)
	//     tmp = inputReader.readBoolean();
	//     console.log(tmp, typeof tmp);

	//     // To read a single character
	//     tmp = inputReader.readChar();
	//     console.log(tmp, typeof tmp);

	//     // to read a line
	//     tmp = inputReader.readLine();
	//     console.log(tmp, typeof tmp);

	//     // To read a numeric array
	//     tmp = inputReader.readNumberArray();
	//     console.log(tmp, typeof tmp);
	// }

}

var _inputData = '';
function cacheInput(data) {
	_inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', cacheInput).on('end', _main);

function _inputReader () {
	function readArray() {
		return _inputLines[_lineNumber++].split(' ');
	}

	function readBoolean(){
		let word = _inputLines[_lineNumber++];
		if(word.toLowerCase() == "true" || word.toLowerCase() == "1"){
			return true;
		}else {
			return true;
		}
	}

	function readChar(){
		return _inputLines[_lineNumber++].trim();
	}

	function readNumber(){
		return Number(_inputLines[_lineNumber++]);
	}

	function readLine(){
		return _inputLines[_lineNumber++];
	}

	function readNumberArray(){
		return _inputLines[_lineNumber++].split(' ').map(val => Number(val));
	}

	return {
		readArray,
		readBoolean,
		readChar,
		readNumber,
		readLine,
		readNumberArray,
	}
}


const readline = require('readline');

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

rl.on('line', (input) => {
    //console.log(input);
    ar = input.split(' ');

    n = ar[0];
    m = ar[1];
    a = ar[2];

    if (m * n <= a * a) {
        console.log(1);
        return;
    }

    res = Math.ceil(n / a) * Math.ceil(m / a);
    console.log(res);

    rl.close();
});


let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

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

const store = {};

function main() {
	let n = readLine() >> 0;

	let i = 1,
		tries = 0;

	while (i <= n) {
		tries += (n - i) * i + 1;
		i++;
	}

	console.log(tries);
}


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
rl.on('line', (d) => {
  let str = '';
  for (let i = 0; i <= +d; i++) {
    str += i;
  }

  console.log(str[+d]);
});


//Beautiful Matrix

const {EOL} = require('os');

let inp = '';

process.stdin.on('data', c => inp += c);

process.stdin.on('end', () => {
    let lines = inp.split(EOL);

    let loc = [];
    for(let i in lines)  {
    	if(lines[i].indexOf('1') != -1)  {
    		loc = [+i, ~~(lines[i].indexOf('1') / 2)];
    	}
    }

    process.stdout.write(Math.abs(2 - loc[0]) + Math.abs(2 - loc[1]) + '');

    return;
});


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

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const [year] = input;

    for (i = parseInt(year) + 1; i < 10000; i++) {
        let y = i.toString();
        let l = y.length;

        let ll = y.split('').filter((val, index, arr) => {
            return arr.indexOf(val) === index;
        }).length;

        if(l === ll) {
            console.log(i);
            break;
        }
    }
});


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var max = Math.max.apply(null, list);
	for(var i = max; i <= 300; i++){
		var L = 0;
		var R = 0;
		for(var j = 0; j < N; j++){
			L += list[j];
			R += i - list[j];
		}
		if(L < R){
			myout(i);
			return;
		}
	}
}


const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
})
var matrix = [];
readline.on("line", ans => {
    matrix.push(ans.split(" "))
    if (matrix.length == 5) {
        var pos = [];
        for (let i = 0; i < matrix.length; i++) {
            for (let j = 0; j < matrix[i].length; j++) {
                matrix[i][j] == 1 ? pos.push(i, j) : void 0;
            }
        }
        var res = 0;
        for (let k = 0; k < pos.length; k++) {
            res += Math.abs(pos[k] - 2);
        }
        console.log(res);
        readline.close();
    }
})


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

  // multi line input
readline.on('line', line => {
   let strings = line
   console.log(stringTask(strings))
})

//it's a main function stringTask
function stringTask(strings) {
   let lowerLetter = strings.toLowerCase()
   let findeLetterWithOutVowels = lowerLetter.replace(/[aeiouy]/g, '')

   return findeLetterWithOutVowels.replace(/(\w)/g, ('.$1'))
}


let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', sol);

function sol() {
  const A = input
    .split(' ')
    .map(Number);
  const sum = A.reduce((a, b) => a + b, 0);
  const result =
    (A[0] === sum - A[0]) ||
    (A[1] === sum - A[1]) ||
    (A[2] === sum - A[2]) ||
    (A[3] === sum - A[3]) ||
    (A[0] + A[1] === A[2] + A[3]) ||
    (A[0] + A[2] === A[1] + A[3]) ||
    (A[0] + A[3] === A[1] + A[2])

  process.stdout.write(
    result ? 'YES' : 'NO',
    'utf8',
    () => process.stdout.end()
  );
}


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

const input = [];
readLine.on('line', line => input.push(line));
const year = () => {
    let boolean = false;
    let c = +input[0];
    while (boolean === false) {
        c++; //1988
        let newString = `${c}`;
        let ar = [];
        for (const x of newString) {
            ar.push(x); // 1 9 8 8
        }
        let j = new Set(ar); // 1 9 8
         if (ar.length === j.size) {
             console.log(c);
             boolean = true;
         }
    }

};
readLine.on('close', year);


const readline = require('readline')

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

rl.on("line", main)
let i = 0;
let n = 0;
let m = []
function main(input){

	m.push(input.split(' '))
	i++
	if(i < 5){
		return
	}

	let x = 0
	let y = 0
	for(var j = 0; j < 5; j++){
		for(var k = 0 ; k < 5; k++){
			if(m[j][k] === "1"){
				y = j
				x = k
			}
		}
	}

	console.log(Math.abs((x+1)-3) + Math.abs((y+1)-3))
}


let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  let [count0, found1] = [0, false];
  const str = readLine();

  for (let i = 0; i < str.length; i++) {
    if (!found1 && str[i] === "1") found1 = true;
    if (found1 && str[i] === "0") count0++;
  }

  if (count0 >= 6 && found1) console.log("yes");
  else console.log("no");
}


const lines = [];

const helpers = {
  arrStringtoInt: (arr, splitter) => {
    return arr.split(splitter).map(num => parseInt(num));
  },
  insterAt: (arr, idx, item) => {
    const newArray = [...arr];
    newArray.splice(idx, 0, item);
    return newArray;
  },
  sortAscending: (arr) => {
    return arr.sort((a, b) => a - b);
  },
  sortDescending(arr) {
    return arr.sort((a, b) => b - a);
  }
}

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

// multi line input
readline.on('line', line => {
  lines.push(line);
});

readline.on('close', line => {
  const matchs = [];
  let total = 0;

  for (let x = 1; x < lines.length; x++) {
    const m = helpers.arrStringtoInt(lines[x], ' ');
    matchs.push(m);
  }

  // [ [1,2], [2,4], [3,4]  ]

  let n = matchs.length;

  for (let y = 0; y < n; y++) {

    for (let x = 0; x < n; x++) {
      if (y != x) {
        if(matchs[y][0] == matchs[x][1]) {
          total++;
        }
      }
    }
  }

  console.log(total)

});


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

rl.on('line', (d) => {
  let ans = 0;
  let [n, k] = d.split(' ').map(Number);
  let time = 240;
  time -= k;

  let c = 1;
  let inc = 5;
  while (time > 0 && n > 0) {
    time -= inc * c;

    if (time >= 0) {
      ans++;
      n--;
      c++;
    }
  }

  console.log(ans);
});


  const readline = require('readline');

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

  rl.question('', (value) => {
      let s = value;
      let isPalindrome = true;
      let oneLetter = true;
      for(let idx = 0; idx < Math.floor(s.length/2) && isPalindrome; idx += 1){
        if(s.charAt(idx) != s.charAt(s.length-idx-1)){
          isPalindrome = false;
        }
        if(s[idx] !== s[idx+1] && oneLetter){
          oneLetter = false;
        }
      }
      if(!isPalindrome){
        console.log(s.length);
      }else if(oneLetter) {
        console.log(0);
      }else {
        console.log(s.length-1);
      }
      rl.close();

  });


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

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

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => a - b);
  console.log(arr[Math.floor(arr.length / 2)]);

  c++;
});


'use strict';
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();
});

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let counts={}
	let userName=readLine()

	let set = new Set()
	for(let char of userName)
		set.add(char)

	if(set.size%2==0)
		console.log('CHAT WITH HER!')
	else console.log('IGNORE HIM!')
}


let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

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

function main() {
	const [n, x] = readLine()
		.split(' ')
		.map(x => x >> 0);
	let count = 0;

	for (let i = 1; i <= n; i++) {
		if (x % i === 0 && x / i <= n) {
			count++;
		}
	}

	console.log(count);
}


function main(input) {

       // console.log(input,"ii");
       input =input.split(/\n/g);
       let p = input[0].split(' ');
       // l = a.length;
       let n = parseInt(p[0]);
       let a = parseInt(p[1]);
       let x= parseInt(p[2]);
       let b = parseInt(p[3]);
       let y = parseInt(p[4]);
       var print = "NO";
       let gg =x;
       let ll =y;
    //    if(b>y) {
    //        ll = parseInt(b)-parseInt(y);
    //    } else {
    //        // ll = parseInt(y)+ parseInt(n) - parseInt(b) ;
    //        ll = b + n - y -1;
    //    }

    //    if(a<x) {
    //        gg = parseInt(x)-parseInt(a);
    //    } else {
    //        gg = parseInt(n)+ parseInt(a) - parseInt(x) -1 ;
    //    }

        //  let min = Math.min(gg,ll,parseInt(n));

        //  console.log(min,"hhh")
       for(let i =0;i< n;i++){
        //    if(a== gg || b== ll) break;
           if(b==0){
           // console.log('ooooooooo')
            b=parseInt(n)
        };
           if(a==n+1){
               a= 1;
           }
        //    console.log(i,'-----',a,'----',b);
           if(a==b){
               // console.log();
               print = "YES";
               break;
           } else if(a== gg || b== ll){
               break;
           } else {
               a++;
               b--;
           }
        //    } else {

        //        a++;
        //        b--;

        //    }
        //    if(a== gg || b== ll) break;
       }
       console.log(print);

}

// main('10 2 1 9 10');

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
   stdin_input += input;
});

process.stdin.on("end", function () {
  main(stdin_input);
});


/**
 * Codeforces Challenge #1204B
 *    @ennukee
 *
 * Time Elapsed: 5.64ms (test cases)
 */

const MODE = "SUBMIT";
const CF_1204_B = (n, l, r) =>  {
    /**
     * n, n-1, ..., n-l, 2^1, ..., 2^(l-1)
     * 2^1, ..., 2^(r-1), 2^(r-1), ..., 2^(r-1)
     *
     * 5, 2, 3
     * => 1, 1, 1, 2
     * => 1, 2, 4, 4, 4
     */
    const low_bound = 1 * (n - l + 1) + [...Array(l).keys()].slice(1).reduce((a, c) => a + Math.pow(2, c), 0);
    const high_bound = [...Array(r).keys()].reduce((a, c) => a + Math.pow(2, c), 0) + (n - r) * Math.pow(2, r - 1);
    return `${low_bound} ${high_bound}`;
}

/**
 *
 * Submission standard input read-in
 *
 */

if (MODE === "SUBMIT") {
    var readline = require('readline');

    var rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });

    rl.question("", function(answer) {
        const parsed = answer.split(' ').map(i => parseInt(i));
        console.log(CF_1204_B(...parsed));
        rl.close();
    });
}

/**
 *
 * Test cases and benchmarking code below this point
 *
 * Unrelated to the solution code
 *
 */

if (MODE === "TEST") {
    const { performance } = require('perf_hooks');
    let timer = performance.now();

    // Assumptions:
    //   1 <= n <= 1000
    //   1 <= l <= r <= min(n, 20)
    //   [n, l, r]
    const test_cases = [
        [4, 2, 2],
        [5, 1, 5]
    ]
    test_cases.forEach(( v ) => {
        console.log( CF_1204_B( ...v ) );
    });

    timer = performance.now() - timer;
    console.log(`Time elapsed for test case: ${timer.toFixed(2)}ms`)
}


const readline = require('readline');

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

let s ;
let upperCounter = 0 ;
let lowerCounter = 0 ;
let temp ;
rl.on("line",(input)=>{
    s = input.split(" ").toString()
    //console.log(typeof(s))
    temp = s;
   // console.log(temp[0].toLowerCase,s[0])

    for(let i = 0 ; i < s.length ; i++){
        if((temp[i].toLowerCase()) == s[i]) lowerCounter++
        else upperCounter++;
    }
    if(lowerCounter>= upperCounter) console.log(s.toLowerCase())
    else console.log(s.toUpperCase());
});


const data = [];
process.stdin.on('data', (chunk) => data.push(chunk));

process.stdin.on('end', () => {
    const n = +(data.join('').trim());
    console.log(n % 2 || n === 2 ? 'NO' : 'YES')
});


const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
})
readline.question("",(ans)=>{
    console.log(ans.match(/(.)\1{6,}/)?"YES":"NO")
    readline.close();
})


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var s = next();
  var t = next();
  var output = "";
  for(var i = 0; i < s.length; i++){
    if(s[i] != t[i]){
      output += "1";
    }else{
      output += "0";
    }
  }
  myout(output);
}


const state = { stdin: Buffer.alloc(0) };
const consume = (chunk) =>
  (state.stdin = Buffer.concat(
    [state.stdin, chunk],
    state.stdin.length + chunk.length
  ));
const commit = (answer) => process.stdout.write(answer);
//
const main = (args) => {
  let data = parseInt(state.stdin.toString("utf8"));
  let solution = "NO";
  if (data < 1 || data > 100) return commit(solution);

  // divide the watermelon into two parts,
  // each of them weighing even (%2==0) number of kilos;

  for (let i = 1; i < data; i++) {
    let partOne = data - i;
    let partTwo = data - partOne;
    if (partOne % 2 === 0 && partTwo % 2 === 0) {
      solution = "YES";
    //   console.log(data, partOne, partTwo)
      commit(solution);
      return;
    }
  }
  commit(solution);
};

process.stdin.on("data", consume).on("end", main);


'use strict';

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++];
}

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const numOfInterestingMinutes = readline();
  const interestingMinutes = readline();

  countNumberOfMinutes(
    parseInt(numOfInterestingMinutes),
    interestingMinutes.split(' ')
  );
}

function countNumberOfMinutes(numOfInterestingMinutes, interestingMinutes) {
  const firstInterestingMinute = parseInt(interestingMinutes[0])
  if (firstInterestingMinute >= 16) {
    console.log(15);
    return;
  }

  if (numOfInterestingMinutes === 1) {
    console.log(firstInterestingMinute + 15);
    return;
  }

  let watchMinutes = firstInterestingMinute;
  let diff = 0

  for (let i = 1; i < numOfInterestingMinutes; i++) {
    diff =
      parseInt(interestingMinutes[i]) - parseInt(interestingMinutes[i - 1]);
    if (diff >= 16) {
      watchMinutes += 15;
      break;
    } else {
      watchMinutes += diff;
    }
  }

  if (diff < 16)
    watchMinutes += 15

  console.log(watchMinutes >= 90 ? 90 : watchMinutes);
}


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

const input = [];
readLine.on('line', line => input.push(line));

const nextRound = () => {
    let count = 0;
    const [n, k] = input[0].split(' ').map(x => +x);
    const ar = input[1].split(' ').map(x => +x);
    for (const x of ar) {
        if ((x >= ar[k-1]) && (x >0)) {
            count++;
        }
    }
    console.log(count);
};

readLine.on('close', nextRound);


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

const input = [];

rl.on('line', line => {
    input.push(line);
});

rl.on('close', () => {
    solution(input[0], input[1]);
});

function solution(first, second) {
    for (let i = 0; i < first.length; i++) {
        if (first[i].toLowerCase() > second[i].toLowerCase()) {
            console.log('1');
            return;
        } else if (first[i].toLowerCase() < second[i].toLowerCase()) {
            console.log('-1');
            return;
        }
    }

    console.log('0');
    return;
}


'use strict'
process.stdin.on('data', data => {
  data = data.toString()
  const [n, m, a] = data.split(' ').map(a => parseInt(a))
  console.log(Math.ceil(n / a) * Math.ceil(m / a))
})


var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var a,b;
var expect = 'first_string';
rl.on('line', function(line){
    if(expect == 'first_string'){
        a = line.toLowerCase();
        expect = 'second_string';
    }else {
        b = line.toLowerCase();
        console.log(a.localeCompare(b));
        process.exit(0);
    }
});


function main() {
    // write code here:
    var n=Number(stdin[0]),m=0;
    for(var i=1;i<n;i++){
        if((n-i)%i===0){
            m++;
        }
    }
    console.log(m);
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {
    stdin.push(line);
});
rl.on('close', main);


const readline = require('readline');

const rl = readline.createInterface({ input: process.stdin });

rl.question('', str => {
  word = 'hello'
  i = 0
  for(l of str) if(l == word[i]) i++
  console.log(i == word.length ? 'YES' : 'NO')
  rl.close();
});


'use strict';

function createReadLine() {
  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++];
  }

  return readline;
}

const readline = createReadLine();

function readInts(){
  return readline().split(' ').map((value => Number.parseInt(value)));
}

function readFloats(){
  return readline().split(' ').map((value => Number.parseFloat(value)));
}

function readStr() {
  return readline();
}

function readInt(){
  return Number.parseInt(readline());
}

function readFloat(){
  return Number.parseFloat(readline());
}

function main() {
  const str = readStr();
  const result = solve(str);
  console.log(result);
}

function solve(str){
  const strArr = str.toString().split('')
  let number = Number.parseInt(str);
  let counter = 0;
  while (number > 0){
    number = number - Math.max(...number.toString().split(''))
    counter ++;
  }
  return counter;
}

module.exports.solve = solve;


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

rl.on('line', (d) => {
  const arr = d.split(' ').map(Number);
  const sum = arr.reduce((a, b) => a + b, 0);
  const obj = {0: 0};
  let best = sum;

  for (let i = 0; i < arr.length; i++) {
    if (obj[arr[i]]) {
      obj[arr[i]] = Math.min(3, obj[arr[i]] + 1);
    }
    else {
      obj[arr[i]] = 1;
    }
  }

  for (let key in obj) {
    if (obj[key] > 1) {
      const val = key * obj[key];
      best = Math.min(best, sum - val);
    }
  }

  console.log(best);

  c++;
});


let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const tuple = enhance(parseInt(lines[0], 10));
  console.log(`${tuple[1]} ${tuple[0]}`);
});

function enhance(hp) {
  const tuple = ['D', 0];
  for (let i = 0; i <= 2; i++) {
    const remainder = (hp + i) % 4;
    if (remainder === 1) {
      if ('A' < tuple[0]) {
        tuple[0] = 'A';
        tuple[1] = i;
      }
    }
    if (remainder === 3) {
      if ('B' < tuple[0]) {
        tuple[0] = 'B';
        tuple[1] = i;
      }
    }
    if (remainder === 2) {
      if ('C' < tuple[0]) {
        tuple[0] = 'C';
        tuple[1] = i;
      }
    }
  }
  return tuple;
}


function findGreeting( input ) {
  const greeting = 'hello';

  if ( input.length < greeting.length ) {
    return 'NO';
  }

  const inputArr = Array.from( input );
  let index = 0;

  for ( let i = 0; i < inputArr.length; i++ ) {
    const char = inputArr[ i ];

    if ( char === greeting[ index ] ) {
      index++;
    }
  }

  if ( greeting.length <= index ) {
    return 'YES';
  }

  return 'NO';
}

const { EOL } = require('os');

let i = '';

process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const lines = i.split(EOL)
    const res = findGreeting(lines[0])
    console.log(res);
})


// http://codeforces.com/problemset/problem/977/A
module.exports = solve;
function solve(line) {
    let [a, b] = line.split(' ').map(n => Number.parseInt(n, 10));
    let i = 0;
    while(a <= b) {
        a *= 3;
        b *= 2;
        i++;
    }
    return i;
    // console.log(line, a, b);
    // return Math.ceil(Math.log2(b / a) / Math.log2(3 / 2));
}

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

let i = 1;
rl.on('line', (line) => {
    if (i++) {
        console.log(solve(line))
        rl.close();
    }
});


const readline = require('readline');

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let grid = [];
// Read Inputs

rl.on('line', lineInput => {
    grid.push(lineInput);
})
rl.on('close', () => {
    let r = grid[0].split(" ")[0];
    let c = grid[0].split(" ")[1];

    // rows
    let clearRows = 0, rows = [];
    for (let i = 1; i <= r; i++) {
        const row = grid[i];
        rows.push(row)
        if (!row.split('').includes('S'))
            clearRows++;
    }

    // cols
    let clearCols = 0;
    for (let i = 0; i < c; i++) {
        let f = 0;
        for (let j = 0; j < r; j++) {
            const box = rows[j].split('')[i];
            if (box === 'S') { f = 1; break; }
        }
        if (!f)
            clearCols++;
    }
    let overlaps = clearCols * clearRows;
    let ans = ((clearCols * r) + (clearRows * c)) - overlaps

    console.log(ans)

});


const input = [];

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

RL.on('line', line => input.push(line));

RL.on('close', () => {
  let [n, k] = input[0].split(' ').map(x => parseInt(x));

  for (let i = 0; i < k; i += 1) {
    if (n % 10 === 0) n /= 10;
    else n -= 1;
  }

  console.log(n);
});


'use strict'; /*jslint node:true, browser:true, es6:true*/
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
const print = console.log
const lines = []
rl.on('line', line => {
    lines.push(line);
});
rl.on('close', main)
let rli = 0;
function readline() {
    return lines[rli++];
}

let mem = new Map();
function query(n){
    let RES = 0;
    for (let i=1; i<=9; i++)
    {
        let k = i;
        let res = 0;
        while (k<10000)
        {
            res++;
            RES += res;
            if (k==n)
                return RES;
            k = (k*10)+i;
        }
    }
    return RES
}

function main() {
    var q = +readline();
    while (q--)
    {
        var n = +readline();
        print(query(n));
    }
}


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const N = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'B', 'H']
  let [a, b, c] = ipt.split(EOL)[0].split(' ').map(n => N.indexOf(n)).sort((a, b) => a - b)
  if (
       12 - c + a == 3 && b - a == 4
    || b - a == 3 && c - b == 4
    || c - b == 3 && 12 - c + a == 4
  ) console.log('minor')
  else if (
       12 - c + a == 4 && b - a == 3
    || b - a == 4 && c - b == 3
    || c - b == 4 && 12 - c + a == 3
  ) console.log('major')
  else console.log('strange')
})


process.stdin.resume()
process.stdin.setEncoding('utf8')

let currentLine = 0
let inputString = ''

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

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

function readLine() {
    return inputString[currentLine++]
}

function main() {
    const [n, m] = readLine().trim().split(' ').map(Number)
    let middle = 0
    // even
    if(n % 2 === 0) {
        middle = parseInt(n/2);
        if(m <=middle) {
            console.log(m + (m-1))
        } else {
            console.log((m-middle) * 2)
        }

    } else if(n % 2 !== 0) {
        middle = parseInt((n/2) + 1);
        if(m <= middle) {
            console.log(m + (m-1))
        } else {
            console.log((m-middle) * 2)
        }
    }

}


const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {

    const nums = inputs.map(num => parseInt(num));

    let maxValue = nums[0] * (nums[1] + nums[2]);

    maxValue = Math.max(maxValue, (nums[0] * nums[1]) * nums[2])
    maxValue = Math.max(maxValue, (nums[0] + nums[1]) + nums[2])
    maxValue = Math.max(maxValue, (nums[0] + nums[1]) * nums[2])

    console.log(maxValue)
})


'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rn = async () => Number(await read());
  const n = await rn();
  const check = m => {
    let ans = Math.floor((m - 1) / 2);
    if (m > 4) ans += Math.floor(m / 4) - 1;
    return ans >= n;
  };
  let l = 3,
      r = 10 ** 12;
  while (l < r) {
    const m = Math.floor((l + r) / 2);
    if (check(m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  return l;
}

async function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log('zdebug' + error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();


// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {
    let input = str.trim().split('\n');
    let numeric = input[0].split(' ');
    let seconds = +numeric[1];
    let bg = input[1].split('');
    let newbg = [...bg];
    for (let i = 0; i < seconds; i++) {

        for (let i = 1; i < bg.length; i++) {
            if (bg[i - 1] < bg[i]) {
                let temp = bg[i - 1];
                newbg[i - 1] = bg[i];
                newbg[i] = temp;
            }
        }
        bg = newbg;
        newbg = [...bg];
    }
    return bg.join('').toString();
}


process.stdin.on('data', input => {
  const tests = input.toString().split('\n');
  console.log(check(tests));
});

function check(tests) {
  const str1 = tests[0].trim();
  const str2 = tests[1].trim();

  // Both strings length are same.
  let flag = 0;
  for (let index = 0; index < str1.length; index++) {
    const s1 = str1[index].toLowerCase();
    const s2 = str2[index].toLowerCase();
    if (s1 === s2) {
      flag = 0;
    } else if (s1 > s2) {
      flag = 1;
      break;
    } else {
      flag = -1;
      break;
    }
  }

  return flag;
}


const readline = require("readline");

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
rl.question("", (N) => {
  N = parseInt(N);
  if (N % 2 == 0 && N >= 4) {
    console.log("YES");
  } else {
    console.log("NO");
  }
  rl.close();
});


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let n, k;

rl.on('line', (d) => {
  if (c === 0) {
    [n, k] = d.split(' ').map(Number);
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => a - b);

  let ans = 0;

  for (let i = 0; i < arr.length; i++) {
    if (k % arr[i] === 0) {
      ans = k / arr[i];
    }
  }

  console.log(ans);

  c++;
});


const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let input = [];
rl.on('line', (inputString) => {
    let [x, y] = inputString.split(' ').map(v => parseInt(v));
    input = input.concat([x, y]);
    if (input.length == 6) {
        let [w, h, u1, d1, u2, d2] = input;
        for (; h >= 0; h--) {
            w += h;
            if (h == d1) w -= u1;
            if (h == d2) w -= u2;
            if (w < 0) w = 0;
        }
        console.log(w);
        process.exit();
    }
});


const funkyNumbers = n => {
    let funkyNumber = 'NO';

    const maxTriangle = maxTrianglePossible(n);

    for(let i = maxTriangle; i > 0; i--) {
        const firstTriangle = triangleNumbers(i);
        const rem = n - firstTriangle;

        if(rem === 0) continue;

        const secFactor = maxTrianglePossible(rem);
        const secTriangle = triangleNumbers(secFactor);

        const triangles = firstTriangle + secTriangle;

        if(triangles == n) {
            funkyNumber = 'YES';
            break;
        }
    }

    return funkyNumber;
};

//k(k+1) / 2 = n where n is an integer
//k(k+1) = n*2
//k^2 + k - n*2 = 0 -> factors
const maxTrianglePossible = n => Math.floor( Math.sqrt(n*2) );

const triangleNumbers = x => ( x * (x + 1) ) / 2;

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

readline.on('line', n => {
    readline.close();

    const res = funkyNumbers(n);
    console.log(res);
});


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

rl.on("line", (line) => {
  let n = "";
  let m = "";
  [n, m] = line.split(" ");
  for (let index = 1; index <= n; index++) if (index % m === 0) n++;
  console.log(n);
});

rl.on("close", () => {});


const readline = require("readline");

const rl = readline.createInterface(process.stdin);

rl.on("line", line => {
  const letters = new Set(line.split(""));

  if (letters.size % 2) {
    console.log("IGNORE HIM!");
  } else {
    console.log("CHAT WITH HER!");
  }

  process.exit(0);
});


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var map = {0:[list[0]]};
  for(var i = 1; i < N; i++){
  	var key = Object.keys(map);
  	var isOK = false;
  	for(var j = 0; j < key.length; j++){
  		if(map[key[j]].indexOf(list[i]) == -1){
  			isOK = true;
  			map[key[j]].push(list[i]);
  			break;
  		}
  	}
  	if(!isOK){
  		map[key.length] = [list[i]];
  	}
  }
  myerr(map);
  myout(Object.keys(map).length);
}


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

rl.on('line', (str) => {
  let a = 0;
  let x = 0;

  for (let i = 0; i < str.length; i++) {
    if (str[i] === 'a') {
      a++;
    }
    else {
      x++;
    }
  }

  if (a <= x) {
    console.log(str.length - (x - a + 1));
  }
  else {
    console.log(str.length);
  }
});


'use strict';

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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let num = readLine()
        .split('')
        .map(value => parseInt(value));
    let only7and4 = num.filter((value) => {
        return value == 7 || value == 4;
    })
    if (only7and4.length == 4 || only7and4.length == 7) {
        console.log('YES');
    } else console.log('NO');
}


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

let l = 0;
rl.on('line', (input) => {
        rl.close();
        let inp = input.split(" ").map(x => parseInt(x))
        let  res = Math.ceil((inp[0]*8)/inp[1]) + Math.ceil((inp[0]*5)/inp[1]) + Math.ceil((inp[0]*2)/inp[1])
        console.log(res)
        return 0;
});


var readline = require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
var STATE = 1;
var a, b, c;
rl.on('line', function (input) {
  var params = input.split(' ');
  a = parseInt(params[0], 10);
  b = parseInt(params[1], 10);
  c = parseInt(params[2], 10);
  // console.log(STATE + ':', a,b,c);

  if (b !== a) {
    console.log(Math.min(a,b) * 2 + 2 * c + 1);
  } else {
    console.log(Math.min(a,b) * 2 + 2 * c);
  }
}).on('close', function() {
  process.exit(0);
});


/**
 * ilya and bank account
 */
function ilyaAndBankAccount(line) {
  if (line > 0) console.log(parseInt(line) + "");
  else {
    line = line.split("");
    if (line.length == 2) console.log(0);
    else {
      if (line[line.length - 1] > line[line.length - 2]) {
        line.pop();
        line = line.join("");
        console.log(parseInt(line) + "");
      } else {
        let save = line.pop();
        line.pop();
        line.push(save);
        line = line.join("");
        console.log(parseInt(line) + "");
      }
    }
  }
}

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

rl.on("line", (line) => {
  ilyaAndBankAccount(line);
});
rl.on("close", () => {});


// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.trim().split('\n');
    let alphabets = inputs[1];
    let alphabetFound = [];
    for (let i = 65; i <= 90; i++) {
        let caps = String.fromCharCode(i);
        let small = caps.toLowerCase();
        let capIndex = alphabets.indexOf(caps);
        let smallIndex = alphabets.indexOf(small);
        if (capIndex !== -1 || smallIndex !== -1) {
            let index = capIndex !== -1 ? capIndex : smallIndex;
            alphabetFound.push(alphabets[index]);
        }
    }

    let msg = alphabetFound.length === 26 ? 'YES' : 'NO';

    return msg.toString();
}


var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

const MOD = 1000000007n;

function fast_pow(a, p)
{
	let res = 1n;
	while (p) {
		if (p % 2n == 0) {
			a = a * a % MOD;
			p /= 2n;
		} else {
			res = res * a % MOD;
			p--;
		}
	}
	return res;
}

function main () {
	const k = rn();

	const ans = fast_pow(4n, 2n**BigInt(k)-2n) * 6n % MOD;

	console.log(ans.toString());
}


const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
let stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', solution);

function solution() {
  let line = stdin[0].split(' ');
  var n = parseInt(line[0]);
  var k = parseInt(line[1]);

  var main = function(n, k){
    res = n;
    var getLastDigit = function(d){
      last = d%10;
      return +last;
    };

    for (i = 0; i < k; i++){
      var lastDigit = getLastDigit(res);
      //if the last digit of the number is non-zero, she decreases the number by one;
      // the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit).
      if (lastDigit !== 0) {
        res--;
      } else {
        res = res/10;
      }
    }
    return res;
  }

  var result = main(n, k);
  console.log(result);
  return result;
}


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

let firstLine = true;
let winIndex;

rl.on('line', (line) => {
    if (firstLine) {
        winIndex = parseInt(line.split(' ')[1]) - 1; // to zero-based :)
        firstLine = false;
    } else {
        const points = line.split(' ').map(i => parseInt(i));

        while(points[winIndex] === 0 && winIndex > 0) {
            winIndex--;
        }
        if (points[winIndex] === 0) {
            console.log(0);
            return;
        }

        let i = winIndex + 1;
        while (points[i] && points[i] === points[winIndex]) {
            i++;
        }

        console.log(i);
    }
});


// NYAN NYAN
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░░░░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░░░░░░░░░
// ░░░░░░░░▄▀░░░░░░░░░░░░▄░░░░░░░▀▄░░░░░░░
// ░░░░░░░░█░░▄░░░░▄░░░░░░░░░░░░░░█░░░░░░░
// ░░░░░░░░█░░░░░░░░░░░░▄█▄▄░░▄░░░█░▄▄▄░░░
// ░▄▄▄▄▄░░█░░░░░░▀░░░░▀█░░▀▄░░░░░█▀▀░██░░
// ░██▄▀██▄█░░░▄░░░░░░░██░░░░▀▀▀▀▀░░░░██░░
// ░░▀██▄▀██░░░░░░░░▀░██▀░░░░░░░░░░░░░▀██░
// ░░░░▀████░▀░░░░▄░░░██░░░▄█░░░░▄░▄█░░██░
// ░░░░░░░▀█░░░░▄░░░░░██░░░░▄░░░▄░░▄░░░██░
// ░░░░░░░▄█▄░░░░░░░░░░░▀▄░░▀▀▀▀▀▀▀▀░░▄▀░░
// ░░░░░░█▀▀█████████▀▀▀▀████████████▀░░░░
// ░░░░░░████▀░░███▀░░░░░░▀███░░▀██▀░░░░░░
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

// 백준의 노드 버전이 너무 낮아 babel 사용.
// 풀이는 solve() 함수에 있음.

const CODEFORCES_NODE = "cf";
const CODEFORCES_V8 = "cf-v8";
const BEAKJOON = "bj";
const TEST = "test";
// var SITE = BEAKJOON;
var SITE = CODEFORCES_NODE;
var DEBUG = false;

if(SITE == BEAKJOON){
  if (!String.prototype.startsWith) {
    String.prototype.startsWith = function(search, pos) {
      return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
    };
  }
  if (!String.prototype.endsWith) {
    String.prototype.endsWith = function(search, this_len) {
      if (this_len === undefined || this_len > this.length) {
        this_len = this.length;
      }
      return this.substring(this_len - search.length, this_len) === search;
    };
  }
  if (!String.prototype.repeat) {
    String.prototype.repeat = function(count) {
      'use strict';
      if (this == null) {
        throw new TypeError('can\'t convert ' + this + ' to object');
      }
      var str = '' + this;
      count = +count;
      if (count != count) {
        count = 0;
      }
      if (count < 0) {
        throw new RangeError('repeat count must be non-negative');
      }
      if (count == Infinity) {
        throw new RangeError('repeat count must be less than infinity');
      }
      count = Math.floor(count);
      if (str.length == 0 || count == 0) {
        return '';
      }
      // Ensuring count is a 31-bit integer allows us to heavily optimize the
      // main part. But anyway, most current (August 2014) browsers can't handle
      // strings 1 << 28 chars or longer, so:
      if (str.length * count >= 1 << 28) {
        throw new RangeError('repeat count must not overflow maximum string size');
      }
      var maxCount = str.length * count;
      count = Math.floor(Math.log(count) / Math.log(2));
      while (count) {
         str += str;
         count--;
      }
      str += str.substring(0, maxCount - str.length);
      return str;
    }
  }
}

String.prototype.replaceAt=function(index, replacement) {
  return this.substr(0, index) + replacement+ this.substr(index + replacement.length);
}

Function.prototype.repeat = function(times){
  for(let i = 0; i < times; i++){
    this();
  }
}

Array.prototype.getMaxConsecutiveSum = function(defaultValue = -Infinity){
  const N = this.length;
  let maxsum = defaultValue;
  let cursum = defaultValue;
  let cur;
  for(var ii = 0; ii < N; ii++){
    cur = this[ii];
    if(cursum + cur > 0){
      if(cur > cursum + cur){
        cursum = cur;
      } else cursum += cur;
    } else {
      cursum = cur;
      if(maxsum < cursum){
        maxsum = cursum;
      }
    }
    if(maxsum < cursum){
      maxsum = cursum;
    }
  }
  this.maxConsecutiveSum = maxsum;
  return maxsum;
}

try {
  require('manakin').global;
  // require ("babel-polyfill");
} catch (error) {

}
try {
  process.argv.forEach(function (val, index, array) {
    if (val.startsWith("site")) {
      switch (val.split("=")[1]) {
        case "test":
          // console.log('change site to test')
          SITE = TEST;
          break;
        case "cf-node":
          // console.log('change site to cf')
          SITE = CODEFORCES_NODE;
          break;
        case "cf":
          // console.log('change site to cf')
          SITE = CODEFORCES_NODE;
          break;
        case "cf-v8":
          // console.log('change site to cf')
          SITE = CODEFORCES_V8;
          break;
        case "bj":
          // console.log('change site to bj')
          SITE = BEAKJOON;
          break;
      }
    }
    if (val.startsWith("debug")) {
      switch (val.split("=")[1]) {
        case "true":
          DEBUG = true;
          break;
        case "false":
          DEBUG = false;
          break;
      }
    }
  });
} catch (error) {
}

let inputFilePath = '';
switch(SITE){
  case TEST:
    const config = require('config');
    var fs = require("fs");
    var path = require('path');
    inputFilePath = config.get('INPUTFILEPATH') || path.resolve(__dirname, "input.txt");
    break;
  default:
    inputFilePath = './input.txt';
    break;
}
const INPUTFILEPATH = inputFilePath;

// if (!String.prototype.endsWith) {
// 	String.prototype.endsWith = function(search, this_len) {
// 		if (this_len === undefined || this_len > this.length) {
// 			this_len = this.length;
// 		}
// 		return this.substring(this_len - search.length, this_len) === search;
// 	};
// }
// if (!Array.prototype.includes) {
//   Array.prototype.includes = function (target) {
//     return this.indexOf(target) !== -1
//   }
// }

const newLine = '\n';
var ans;
var inputText = "";
var lineCount = 0;
var lines;
var input;
var readline;
var getlines;
var lineOpen = false;
var readingLine = '';

var clockStart;
var clock;

var print;
print = console.log;
var it;
var step;
function EnableLogging(){
  it = console.info;
  step = console.success;
}
function DisableLogging(){
  it = function it(params) {
    return 0;
  }
  step = it;
}
if (DEBUG) {
  EnableLogging();
  clock = function(start) {
    if ( !start ) return process.hrtime();
    var end = process.hrtime(start);
    return Math.round((end[0]*1000) + (end[1]/1000000));
  }
} else {
  DisableLogging();
}

// prepares test data. to replace line input, assign arrays to lines variable.
function prepareTestData() {
  // it(lines);

  // lines = ['custom line 1', 'custom line 2'];
}

// executes exactly once for both test and run. execution time will be included to elapsed time.
const prepareSolve = () => {

}

function power(x, y) {    //분할 정복을 이용하여 x^y 구하기
  let ret = 1;
  while (y > 0) {
    if (y % 2) {
        ret *= x;
        ret %= P;
    }
    x *= x;
    x %= P;
    y /= 2;
  }
  return ret;
}

function createArray(lengths) {
  var arr = new Array(lengths || 0),
    i = lengths;
  if (arguments.length > 1) {
    var args = Array.prototype.slice.call(arguments, 1);
    while (i--) arr[lengths - 1 - i] = createArray.apply(this, args);
  }
  return arr;
}

// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ MAIN SOLVE FUNCTION ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

function solve(){
  let [n, s] = readInts();

  var asdasd = 0;

  while(s > 0){
    // it(s, n, s%n, Math.floor(s/n), asdasd);
    asdasd = asdasd + Math.floor(s/n);
    s = s%n;
    n = n-1;
  }
  print(asdasd);
}

// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

function resetRead(){
  lineCount = 0;
}

function checkMemoryUsage() {
  it(process.memoryUsage());
}

function readOne(separator=' ') {
  if(lineOpen && readingLine != null){
  // if(lineOpen){
    // it(readingLine);
    let splitPos = readingLine.search(separator)

    let ret = readingLine.slice(0, splitPos);
    if(splitPos == -1){
      // it('close');
      ret = readingLine;
      readingLine = '';
      lineOpen = false;
    }
    readingLine = readingLine.substr(splitPos + 1)
    // it(ret, readingLine, splitPos);
    return ret;
  } else {
    readingLine = readline();
    lineOpen = true;
    if(readingLine == null) return '';
    return readOne(separator);
  }
}

function readInts() {
  try {
    lineOpen = false;
    return readline()
      .split(" ")
      .map(x => parseInt(x));
  } catch (error) {
    console.error(error);
    return null;
  }
}

switch (SITE) {
  case TEST:
    var fs = require("fs");
    var path = require('path');
    // input = fs.createReadStream(path.resolve(__dirname, "input.txt"), {
    //   encoding: "utf8"
    // });
    input = fs.createReadStream(INPUTFILEPATH, {
      encoding: "utf8"
    });

    function inputListener(line) {
      console.log(line);
      if(line.startsWith('end')){
        console.log('end');
        closing();
      }
      if (!line) {
        closing();
      }
      lineCount++;
      inputText += line + "\r\n";
    }

    function readlines() {
      const readline = require("readline");
      const rl = readline.createInterface({
        input,
        output: process.stdout,
        terminal: false
      });
      rl.on("line", inputListener);
      rl.on('close', closing);
    }

    getlines = function* (inputText) {
      var lines = inputText.split(/\r?\n/);
      for (let line of lines) {
        yield line + newLine;
      }
    }

    readline = function () {
      return lines.next().value.trim();
    }

    readlines();

    break;

  case CODEFORCES_NODE:
    input = process.stdin;

    function inputListener(line) {
      if (!line) {
        closing();
      }
      lineCount++;
      inputText += line + "\r\n";
    }

    function readlines() {
      const readline = require("readline");
      const rl = readline.createInterface({
        input,
        output: process.stdout,
        terminal: false
      });
      rl.on("line", inputListener);
      rl.on('close', closing);
    }

    getlines = function* (inputText) {
      var lines = inputText.split(/\r?\n/);
      for (let line of lines) {
        yield line + newLine;
      }
    }

    readline = function () {
      return lines.next().value.trim();
    }

    readlines();

    break;
  case BEAKJOON:
    var fs = require('fs');
    if (DEBUG) {
      // input = fs.readFileSync('./input.txt').toString();
      inputText = fs.readFileSync(INPUTFILEPATH).toString();

    } else {
      inputText = fs.readFileSync('/dev/stdin').toString();
    }

    readline = function () {
      lineCount++;
      let line = lines[lineCount - 1];
      if (line)
        return lines[lineCount - 1].trim();
      else return null;
    }

    getlines = function (inputText) {
      lineCount = 0;
      return inputText.split(/\r?\n/);
    }

    // lines = getlines(input);
    closing();
    break;
  default:
    break;
}

function closing() {
  if(DEBUG){
    DisableLogging();
    const prepareClock = clock();
    lines = getlines(inputText);
    prepareSolve();
    const prepareClockElapsedTime = clock(prepareClock);
    EnableLogging();
    prepareTestData();
    solve();
    resetRead();
    console.warn('performance check');
    DisableLogging();
    clockStart = clock();
    // lines = getlines(inputText);
    solve();
    console.warn(`${clock(clockStart) + prepareClockElapsedTime} ms`);
    EnableLogging();
    process.exit();
  } else {
    lines = getlines(inputText);
    prepareSolve();
    solve();
    process.exit();
  }
}


var readline = require('readline'),
    rl = readline.createInterface(process.stdin, process.stdout);

rl.on('line', function (line) {

    var n=line.split(' ')
    n%2==0 && n!=2 ? console.log("YES") : console.log("NO");
    rl.close();

}).on('close', function () {

    process.exit(0);
});


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

// single line input
// readline.on('line', line => {
//   readline.close(), console.log(line)}
// });

// multi line input
readline.on('line', line => {
  let val = parseFloat(line);
  console.log( val%2 ==0 && val >2? 'YES': 'NO');;
  readline.close();
});


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

let l = 0;
let cups = []
let medals = []

rl.on('line', (input) => {
    if (l === 0) {
        cups = input.split(' ').map(function (item) {
            return parseInt(item, 10);
        });
    } else if (l === 1) {
        medals = input.split(' ').map(function (item) {
            return parseInt(item, 10);
        });
    } else {
        function add(a, b) {
            return a + b;
        }
        rl.close();
        let shelfs = parseInt(input)
        var cupsSum = cups.reduce(add, 0);
        var medalsSum = medals.reduce(add, 0);
        shelfs-=Math.ceil(cupsSum/5)
        shelfs-=Math.ceil(medalsSum/10)
        if(shelfs>=0){
            console.log("YES")
            return 0
        }
        console.log("NO")

        return 0;
    }
    l++
});


function main() {
    // write code here:
    var n=Number(stdin[0]);
    var arr=stdin[1].split('');
    var count=0;
    for(var i=0;i<n;i++){
        if(arr[i+1]===arr[i]){
            count+=1;
        }
    }
    console.log(count);
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {
    stdin.push(line);
});
rl.on('close', main);


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

rl.on('line', function(line){
	if(!line) {
		process.exit()
	}
  const [ancho, largo, baldoza] = line.split(" ").map(n => Number(n));
  const cantidadVertical = Math.ceil(largo / baldoza)
  const cantidadHorizontal = Math.ceil(ancho / baldoza)

  console.log(cantidadVertical * cantidadHorizontal);
})


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;
  const arr = [];
  let inc = 0;

  for (let i = 0; i < str.length - 1; i++) {
    if (str[i] === 'B') {
      inc++;

      if (str[i + 1] === 'W') {
        ans++;
        arr.push(inc);
      }
    }
    else {
      inc = 0;
    }
  }

  if (str[str.length - 1] === 'B') {
    ans++;
    inc++;
    arr.push(inc);
  }

  console.log(ans);
  console.log(arr.join(' '));

  c++;
});


const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
const N = 102;
let n, m, lp = 0;

rl.on('line', (input) => {
    if (lp === 0){
        lp = 1;
        let t = input.split(' ').map((x) => { return parseInt(x); });
        n = t[0];
        m = t[1];
    } else if (lp === 1) {
        let a = input.split(' ').map((x) => { return parseInt(x); });
        let fd = new Array(N);
        let an = new Array(N);
        fd.fill(0);
        for (let i = 0; i < m; i++){
            for (let j = a[i]; j <= n; j++){
                if (fd[j] === 0){
                    an[j] = a[i];
                    fd[j] = 1;
                }
            }
        }
        for (let i = 1; i <= n; i++)console.log(an[i]);
        rl.close();
    }
});


const readline = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
})
readline.question('', (x) => {
    a = [];
    a1 = x.split(' ');
    for (var i = 0; i < a1.length; i++) {
        a.push(Number(a1[i]));
    }
    a.sort((a,b) => {
        return a-b;
    });

    if ((a[0] + a[3] == a[1] + a[2]) || (a[0] + a[1] + a[2] == a[3])) {
        console.log('YES');
    }
    else
        console.log('NO');

    readline.close();
});


let data = '';
process.stdin.on('data', c => data += c);

const solution = () => {
	let line = data.split('\n');
	let n = parseInt(line[0],10);
	let a = line[1].split(' ').map(v => parseInt(v,10));
	let c = 0;
	while(a.length > 0){
		c++;
		let t = [];
		let min = Math.min(...a);
		for(let i of a){
			if (i%min !== 0){
				t.push(i);
			}
		}
		a = t;

	}
	console.log(c);
};

process.stdin.on('end',solution);


let input = [];

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

RL.on('line', (line) => {
    input.push(line);
});

RL.on('close', () => {
    let n = parseInt(input[0]);
    let num = []; input[1].split(' ').forEach(i => num.push(parseInt(i)));
    num.sort((a, b) => a-b);
    let answer = 0;
    for(let i = 1; i < n; i+=2){
        answer += num[i]-num[i-1];
    }
    console.log(answer);
});


// Alternative
// https://www.npmjs.com/package/competitive-programming-js
"use strict"

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 input() { return inputString[currentLine++]; }
const println = (x = "") => process.stdout.write(String(x) + "\n");
const print = x => { process.stdout.write(String(x)); }
// >>>>>>>>>>>>> Main starts here <<<<<<<<<<<<<<

function main() {
    let n = input();
    if (n[0] === '-') {
        if (n.length >= 3) {
            if (parseInt(n[n.length-1]) > parseInt(n[n.length-2])) {
                n = n.substr(0, n.length-1);
            } else {
                n = n.substr(0, n.length-2) + n[n.length-1];
            }
        } else {

        }
    };
    n = parseInt(n);
    println(n);
}


function run(input, count = 0) {
    var i = input.indexOf('xxx');
    if (i == -1) return count;
    else return run(input.substr(i + 1), count + 1)
}

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let input = process.stdin.read();
    input = input.trim();

    if (input !== null && typeof input != 'number') {
        process.stdout.write(run(input) + '\n');
    }

    process.exit(0);

});


'use strict';
// const fs = require('fs');

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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}
function bCoins(n) {
    var arr = [n];
    var i,k,max = n;
    for (i = n-1; i >= 1; i--){
        if(max % i === 0){
          arr.push(i);
          max = i;
        }
    }
    // arr.push(1)
    console.log(arr.join(' '))
}
function main() {
    // const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);

    var res = bCoins(n);

    // ws.write(res.join(' ') + '\n');

    // ws.end();
}


'use strict';

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();
    });

  process.stdout.write(main(inputString));
  process.exit();
});

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

const main = ([inputString]) => {
  const int = parseInt(inputString);
  return int % 2 === 0 && int > 2 ? 'YES' : 'NO';
};


let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

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

const store = {};

function main() {
	let n = readLine() >> 0;

	if (n === 0) {
		console.log(1);
		return;
	}

	let map = { 1: 8, 2: 4, 3: 2, 4: 6 };
	n = n % 4;
	if (n === 0) n = 4;
	console.log(map[n]);
}


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

// var numbers = readline().split(" ").map(function(x) { return parseInt(x); });

readline.on('line', line => {
    readline.close();

    const number = line.split(" ")[0];

    if (number > 2 && number % 2 === 0) {
        console.log('YES');
    } else {
        console.log('NO');
    }
});


/*
===== READ INPUT DATA START =====
=================================
*/

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

let inputString = '';

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

process.stdin.on("end", (_) => {
    const lines = inputString.trim().split("\n").map(string => string.trim()).filter(Boolean);

    main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let N;

  while (T--) {
    N = Number(lines[index++]);
    solve(N);
  }
}

function solve(N) {
  const seen = new Set();
  let result = 1;
  let sqrtN = Math.floor(Math.sqrt(N));
  let a, b;

  for (let n = 2; n <= sqrtN; ++n) {
    a = n ** 2;
    b = n ** 3;

    if (a <= N && !seen.has(a)) {
      result++;
      seen.add(a);
    }

    if (b <= N && !seen.has(b)) {
      result++;
      seen.add(b);
    }
  }

  console.log(result);
}


function solution(num){
    var ret = 0;
    for (var i = 1; i <= num / 2; i++){
        if (num % i == 0)   ret++;
    }
    return ret;
}
process.stdin.addListener("data", (data)=>{
    var num = parseInt(data.toString())

    console.log(solution(num))
})


readline = require('readline')
let stdinInput = '';

function file1(){
    //file
    var fs = require('fs');
   const inputfile = '_in.txt';
   const outputfile = '_out.txt';
   fs.writeFileSync(outputfile, '');
   var myInterface = readline.createInterface({
     input: fs.createReadStream(inputfile),
   });
   myInterface.on('line', function (line) {
      stdinInput += line+'\n';
    }).on('close', () => {
           main();
        process.exit(0);
    })
}

function std1(){
    process.stdin.resume();
    process.stdin.setEncoding('utf-8');
    process.stdin.on('data', (input) => { stdinInput += input; });
    process.stdin.on('end', () => { main(); });
}
   /*
   *  Api Scanner
   */
  class Scanner {
    constructor() {
      this.index = -1;
      this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
    }

    nextLine() {
        if(this.index >= this.lines.length-1)
            return false;
        this.index += 1;
        return this.lines[this.index].trim();
    }
    nextArray(fn) {
        let checkarr = this.nextLine();
        if(checkarr===false)
            return false;
        const array = checkarr.split(' ');
        return fn === String ? array : array.map(fn);
    }

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

// file1();
std1();

let ntest, s1, s2;
function main() {
    const is = new Scanner();

    while(true){
        s1 = is.nextLine();
        if(s1===false)
            return;
        s2 = is.nextLine();

        for(let i=0; i<s1.length; i++){
            if(s1[i]==s2[i])
                process.stdout.write('0');
            else
                process.stdout.write('1');
        }
        process.stdout.write('\n');
    }
}


const solve = (x) => {
    let s = x + '';
    let n = s.length;
    let rest = 0;
    for (let i = 1; i <= n; i++) {
        rest += i;
    }
    return 10 * (s[0] - 1) + rest;
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = Number(input[0][0]);
        let i = 1;
        while (t > 0) {
            let data = input.slice(i, i + 1);
            console.log(solve(data[0][0]));
            t--;
            i++;
        }
    });
};

main()


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

rl.on('line', (d) => {
  const [n, m] = d.split(' ').map(Number);
  const min = Math.min(n, m);

  if (min % 2 === 0) {
    console.log('Malvika');
  }
  else {
    console.log('Akshat');
  }
});


/**
 * Created by ishanarora on 25/11/18.
 */

const stdin = process.openStdin();
let content = ``;
stdin.addListener('data', d => {
  content += d.toString();
});

stdin.addListener('end', () => {
  content = content.split(" ");
 console.log(factors(parseInt(content[0]), parseInt(content[1])));
});

function factors(elem1, elem2) {
    let count = 0;
    for (var i = 1; i <= elem1; i++) {
        if (elem2 % i == 0 && elem2 / i <= elem1) {
            count += 1;
        }
    }
    return count;
}


var input='';

process.stdin.on('data',givenInput=>{
    input+=givenInput;
})

process.stdin.on('end',()=>{
    main(input);
})

const main=(input)=>{
    let num=Number(input.split(' ')[0]);
    const k=Number(input.split(' ')[1]);

    for(let i=0;i<k;i++){

        if(num%10!==0){
            num-=1;
        }
        else{
            num/=10;
        }

    }

    console.log(num);
}


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

rl.on('line', function(line){
    const weight = parseInt(line);
    if(weight <= 2 || weight % 2 !== 0) {
        console.log("NO");
    } else {
        console.log("YES");
    }
})


const readline = require("readline");

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

rl.question("", function (name) {
  var unique = name.split('').filter(function(item, i, ar){ return ar.indexOf(item) === i; }).join('');
  if (unique.length % 2 === 0) {
    console.log("CHAT WITH HER!")
  }
  else {
    console.log("IGNORE HIM!")
  }
  rl.close();
});


let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStd) => {
  inputString += inputStd;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const matrix = [];
  let [_r, _c] = [0, 0];
  const target = 2;
  for (let i = 0; i < 5; i++) {
    let row = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    matrix.push(row);
  }
  for (let row = 0; row < 5; row++) {
    for (let col = 0; col < 5; col++) {
      if (matrix[row][col] === 1) {
        [_r, _c] = [row, col];
        break;
      }
    }
  }
  const dist = Math.abs(target - _r) + Math.abs(target - _c);
  console.log(dist);
}


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

let c = 0;

rl.on("line", (str) => {
  if (str[0] !== "1") {
    console.log("NO");
    return;
  }

  let ans = "YES";
  let prev = str[0];

  for (let i = 1; i < str.length - 1; i++) {
    if (prev === "4" && str[i] === "4" && str[i + 1] === "4") {
      ans = "NO";
      break;
    } else if (str[i] !== "4" && str[i] !== "1") {
      ans = "NO";
      break;
    } else {
      prev = str[i];
    }
  }

  if (str[str.length - 1] !== "4" && str[str.length - 1] !== "1") {
    ans = "NO";
  }

  console.log(ans);

  c++;
});


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

readline.on('line', input => {
  const seq = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard'];
  let segment = 0;
  let segmentFloor = 1;
  let segmentCeiling = 5;

  while (!(input >= segmentFloor && input <= segmentCeiling)) {
    segment++;
    segmentFloor = segmentCeiling + 1;
    segmentCeiling = segmentCeiling + Math.pow(2, segment) * 5;
  }

  const nthAfterFloor = input - segmentFloor + 1;

  const pointer = Math.ceil(nthAfterFloor / Math.pow(2, segment)) - 1;

  console.log(seq[pointer]);
});


let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const [len, limit] = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  const arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  let maxIndex = -1;
  let maxMove = -1;
  for (let i = 0; i < len; i++) {
    const candy = arr[i];
    let move = Math.floor(candy / limit);
    if (candy % limit > 0) move++;
    const diff = candy - limit;

    if (move >= maxMove) {
      if (diff > 0) {
        maxIndex = i;
      }
      maxMove = move;
    }
  }
  maxIndex = maxIndex === -1 ? len - 1 : maxIndex;
  console.log(maxIndex + 1);
}


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

let n, k;

rl.question('', str => {
    [n, k] = str.split(" ");
    solution(n, k);
    rl.close();
});

function solution(n, k) {
    for(let i = 0; i < k; i++) {
        if (n % 10 === 0) n /= 10;
        else n -= 1;
    }
    console.log(n);
}


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var s = next().toUpperCase();
  var set = new Set();
  for(var i = 0; i < N; i++){
    set.add(s[i]);
  }
  myout((set.size == 26) ? "YES" : "NO");
}


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

let l = 0;
rl.on('line', (input) => {
    if (l == 0) { l++ }
    else {
        rl.close();
        let strArray = input.split(" ")
        let s = strArray.map(function (item) {
            return parseInt(item, 10);
        });
        s = s.sort(function sortNumber(a, b) {
            return a - b;
        })
        let res = 0;
        for (let i = 0; i < input.length; i += 2) {
            let d = s[i + 1] - s[i]
            if (d > 0) {
                res += d
            }
        }
        console.log(res)
        return 0;
    }
});


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var alist = nextIntArray();
  var asum = 0;
  var blist = nextIntArray();
  var bsum = 0;
  var N = nextInt();
  for(var i = 0; i < 3; i++){
  	asum += alist[i];
  	bsum += blist[i];
  }
  while(asum > 0){
  	asum -= 5;
  	N--;
  }
  while(bsum > 0){
  	bsum -= 10;
  	N--;
  }

  myout((N < 0) ? "NO" : "YES");

}


'use strict';

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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let n = parseInt(readLine());
    let ans = 0;
    while (n != 0) {
        if (n >= 100) {
            ans += Math.floor(n / 100);
            n -= Math.floor(n / 100) * 100;
        }
        if (n >= 20 && n < 100) {
            ans += Math.floor(n / 20);
            n -= Math.floor(n / 20) * 20;
        }
        if (n >= 10 && n < 20) {
            ans += Math.floor(n / 10);
            n -= Math.floor(n / 10) * 10;
        }
        if (n >= 5 && n < 10) {
            ans += Math.floor(n / 5);
            n -= Math.floor(n / 5) * 5;
        }
        if (n >= 1 && n < 5) {
            ans += Math.floor(n);
            n -= n;
        }
    }
    console.log(ans);
}


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var one = nextIntArray();
	var x = one[0];
	var y = one[1];
	var z = one[2];
	var t1 = one[3];
	var t2 = one[4];
	var t3 = one[5];
	var work = Math.abs(x - y) * t1;
	var eleve = (Math.abs(x - z) * t2) + (t3 * 3) + (Math.abs(x - y) * t2);
	myerr({work, eleve});
	if(eleve <= work){
		myout("YES");
	}else{
		myout("NO");
	}
}


const mainFunction = (lines) => {
    let n, a, b, c, ans = -1;
    [n, a, b, c] = lines[0].split(" ").map(Number)
    for (let i = 0; i <= 4000; i++) {
        for (let j = 0; j <= 4000; j++) {
            let asd = i * a,
                zxc = j * b,
                z = (n - asd - zxc)
            if (z > 0 && z % c === 0) {
                z /= c
                if (i + j + z > ans)
                    ans = i + j + z
            }
            if (asd + zxc === n)
                if (i + j > ans)
                    ans = i + j
        }
    }
    console.log(ans)
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}


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

readline.question("",(w1)=>{
    readline.question("",(w2)=>{
        console.log(w1.toUpperCase().localeCompare(w2.toUpperCase()));
        readline.close();
    })
})


const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {

    const arr = inputs.map(elem => elem.split(' ').map(num => parseInt(num)))
    let n = 0;

    for (let i = 1; i < arr.length; i++) {

        for (let j = 1; j < arr.length; j++) {
            if (arr[i][0] == arr[j][1])
                n++
        }

    }

    console.log(n);

})


'use strict';

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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let n = parseInt(readLine());
    let arr = [];
    let ans = 0;
    for (var i = 0; i < n; i++) {
        arr.push(readLine().split(' ').map(value => parseInt(value)));
    }
    for (var i = 0; i < n; i++) {
        for (var k = 0; k < n; k++) {
            if (arr[i][0] == arr[k][1]) {
                ans++;
            }
        }
    }
    console.log(ans);
}


let stdin = process.openStdin();

stdin.addListener("data", function(input) {
  let string = input.toString().trim().split(' ');
  let subtractedNumber = string[0];
  let count = string[1];

  for (count; count > 0; count--) {
    if (subtractedNumber % 10 === 0) {
      subtractedNumber = subtractedNumber / 10;
    } else {
      subtractedNumber--;
    }
  }

  console.log(subtractedNumber);
  process.exit();
});


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

const input = [];
readLine.on('line', line => input.push(line));

function gdc(x, y) {
  let cx = x, cy = y;
  while (cx != 0 && cy != 0) {
    if (cx > cy) cx = cx % cy;
    else cy = cy % cx;
  }
  return cx + cy;
}

readLine.on('close', () => {
  let [a, b, n] = input[0].split(' ').map(x => parseInt(x));

  let semen = true;
  while (true) {
    let d = gdc(n, semen ? a : b);
    n -= d;

    if (n === 0) { console.log(semen ? 0 : 1); return };
    semen = !semen;
  }
});


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

rl.on('line', (str) => {
  let count = 1;

  for (let i = 1; i < str.length; i++) {
    if (str[i] === str[i - 1]) {
      count++;
    }
    else {
      if (count >= 7) {
        break;
      }

      count = 1;
    }
  }

  console.log(count >= 7 ? 'YES' : 'NO');

  c++;
});


let inputBuffer = "", curLine = 0;

function readline() {
	return inputBuffer[curLine++];
}

let curTokens = [], curToken = 0;

function next() {
	while (curToken >= curTokens.length) {
		curTokens = readline().split(/[\s]+/);
		curToken = 0;
	}
	return curTokens[curToken++];
}

function nextInt () {
	return parseInt(next(), 10);
}

process.stdin.resume();
process.stdin.setEncoding("utf8");

process.stdin.on('data', (chunk) => {
	inputBuffer += chunk;
});

process.stdin.on('end', () => {
	inputBuffer = inputBuffer.trim().split('\n').map(line => line.trim());
	main();
});

function print(data) {
	process.stdout.write(data + "\n");
}

function main () {
	const n = nextInt();

	let f = [];
	f[0] = 0, f[1] = 1, f[2] = 1, f[3] = 1, f[4] = 1, f[5] = 1;
	// console.log(f);
	for(let i = 6; i <= n; i++)
		f[i] = Math.min(f[i-1], f[i-2], f[i-3], f[i-4], f[i-5])+1;
	print(f[n]);
	// console.log(f);
}


let input = [];

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

RL.on('line', (line) => {
    input.push(line);
});

RL.on('close', () => {
   let {0:a, 1:b} = {...input[0].split(' ')};
   a = parseInt(a); b = parseInt(b);
   let f = 0;
   if(a < b) {
    f = fact(a);
   } else {
    f = fact(b);
   }
   console.log(f);
});

function fact(num) {
    if(num === 0)
        return 1;
    return num * fact(num-1);
}


const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var input = [];
rl.on('line', function (line) {input.push(line);});
rl.on('close', function() {
    const word = input[0];
    let lowerCount = 0;
    let upperCount = 0;

    for(let i = 0; i < word.length; i++) {
        if(isUpperCased(word[i])) upperCount++;
        if(!isUpperCased(word[i])) lowerCount++;
    }

    if (upperCount > lowerCount) {
        console.log(word.toUpperCase())
    } else if( lowerCount === upperCount || lowerCount > upperCount) {
        console.log(word.toLowerCase())
    }

});

function isUpperCased(l) {
    return l.toUpperCase() === l;
}


function main(){

var line1 = readline();
var n = parseInt(line1);

var line2 = readline().split(' ').map(Number);

var pos1 = 0;
var posn = 0;

for(i=0;i<n;i++){
    if(line2[i]===1){
	pos1 = i;
    }
    if(line2[i]===n){
	posn = i;
    }
}

if(Math.abs(pos1-posn)===n-1){
    print(n-1);
    return;
}

if(pos1>posn){
    var diff = pos1-posn;
    if(posn>n-1-pos1){
	diff+=posn;
    }
    else{
	diff+=(n-1-pos1);
    }
    print(diff);
    return;
}else{
    var diff = posn-pos1;
    if(pos1>n-1-posn){
	diff+=pos1;
    }else{
	diff+=(n-1-posn);
    }
    print(diff);
    return;
}

}

main();


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

rl.on('line', line => {
    const input = line.split(' ');
    console.log(solution(input));
})

l = console.log;
e = process.exit;

function solution(input) {
    const cost = Number(input[0]);
    const money = Number(input[1]);
    const numberOfBananas = Number(input[2]);
    let total = 0;
    // The banana cost keeps going up
    // k for the first, 2k for the second
    // so let's run an accumulator for this
    for (let i = 1; i <= numberOfBananas; i++) {
        total += i * cost;
    }

    if (total > money) {
        return total - money;
    } else {
        return 0;
    }
}

// Input = 3 17 4
// Output = 13


function main(data) {
	for(let i = parseInt(data[0]) + 1; i < Number.MAX_VALUE; i++) {
		i = i.toString();
		const inputArray = i.split('');
		let ouputArray = Array.from(new Set(inputArray));
		if(inputArray.length == ouputArray.length) {
			console.log(ouputArray.join(''));
			process.exit(0);
		}
	}
}

process.stdin.on('data', data => {
	main(data.toString().trim().split(/\n/));
});


'use strict';
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 number = readline();
    var res= number.replaceAll("144"," ").replaceAll("14"," ").replaceAll("1"," ").trim();
    if(res.length > 0)
    {
        console.log("NO");
    }
    else{
        console.log("YES");
    }
}

String.prototype.replaceAll = function(search, replacement) {
    var target = this;
    return target.split(search).join(replacement);
};


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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  let string1 = input[0].toLowerCase();
  let string2 = input[1].toLowerCase();
  console.log(string1.localeCompare(string2))
});