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

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

readLine.on('close', () => {
  let [m, s] = input[0].split(' ').map(x => parseInt(x));
  if (s === 0 || m*9 < s) {
    if (m === 1 && s === 0)
      console.log(`0 0`);
    else
      console.log(`-1 -1`);
  } else {
    let bigAnswer = [];
    let smallAnswer = [1];
    let smallSumm = s - 1;

    if (s <= 9 && m === 1) {
      console.log(`${s} ${s}`); return;
    }

    if (s <= 9) {
      bigAnswer.push(s);
      bigAnswer = bigAnswer.concat(Array(m-1).fill(0));
    } else {
      while (s !== 0) {
        if (s - 9 < 0) {
          bigAnswer.push(s); break;
        }

        bigAnswer.push(9);
        s -= 9;
      }
      bigAnswer = bigAnswer.concat(Array(m - bigAnswer.length).fill(0));
    }

    let smallTmpNums = [];
    while (smallSumm !== 0) {
      if (smallSumm - 9 < 0) {
        smallTmpNums.push(smallSumm); break;
      }

      smallTmpNums.push(9);
      smallSumm -= 9;
    }

    if (smallTmpNums.length + 1 < m) {
      smallAnswer = smallAnswer.concat(Array( m - (smallTmpNums.length + 1) ).fill(0)).concat(smallTmpNums.reverse());
    } else {
      smallAnswer = smallAnswer.concat(smallTmpNums.reverse());
    }

    console.log(`${smallAnswer.join('')} ${bigAnswer.join('')}`)
  }
});


function main(input) {
    const lines = input.split(EOL);
    const line1 = lines[0].split(' ');
    let n = line1[0] * 1;
    let k = line1[1] * 1;

    while (k--) {
        if (n < 3) break;
        n % 10 === 0 ? n /= 10 : --n;
    }

    console.log(n);
}

const { EOL } = require('os')
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", (input) => _input += input);
process.stdin.on("end", () => main(_input));


// http://codeforces.com/problemset/problem/977/A
function solve(line) {
    let [n, minus] = line.split(' ');
    while (minus--) {
        if(n % 10) n--;
        else n = ~~(n/10);
    }
    return n;
}

if (readline !== undefined) {
    print(solve(readline()));
} else {
    const assert = require('assert').strict;
    const cases = [
        { in: '512 4', out: '50' },
        { in: '1000000000 9', out: '1' },
    ];

    let failed = 0;
    cases.forEach(c => {
        const res = solve(c.in);
        try {
            assert(res.toString() === c.out, 'Expected ' + res + ' to equal ' + c.out);
        } catch (e) {
            failed++;
            print(e.message); }
    });
    if(failed) {
        print(failed + ' failed');
    }else {
        print("pass");
    }
}

function print() {
    console.log(...arguments);
    // process.stdout.write(...args);
}


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

process.stdin.on("data", function(chunk) {
  main(chunk.toString().split("\n"));
});

function main(stdIn = []) {
  let [num, k] = stdIn[0].split(" ");
  while (k > 0) {
    k = num % 10 == 0 ? k - 1 : k - (num % 10);
    num = num % 10 == 0 ? num / 10 : num - (num % 10);
  }
  console.log(num);
}


function solve(n, k){
  for(var i=0; i<k; i++){
    const oneTenth = n/10;
    if(oneTenth % 1 === 0){
      n = oneTenth;
    }else{
      n--;
    }
  }
  return n;
}

var myArgs = process.argv.slice(2);
const n = parseInt(myArgs[0], 10);
const k = parseInt(myArgs[1], 10);
process.stdout.write(solve(n,k) + '');


let input = 1000000000
let times = 9
export default function decrease(num, times) {
  let numStr = num.toString()
  for (let i=0; i<times; i++) {
    if (numStr.endsWith('0')) {
      numStr = (numStr / 10).toString()
    } else {
      numStr = (numStr - 1).toString()
    }
  }
  return numStr
}

const output = decrease(input, times)
console.log(output)


const readline = require('readline')

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

let input = []

rl.on('line', line => {
  input = line.split(' ').map(x => parseInt(x))
  const output = solution(...input)
  console.log(output)
})

rl.on('close', () => {
  console.log(input)
})

function solution(num, times) {
  let numStr = num.toString()
  for (let i=0; i<times; i++) {
    if (numStr.endsWith('0')) {
      numStr = (numStr / 10).toString()
    } else {
      numStr = (numStr - 1).toString()
    }
  }
  return numStr
}


process.stdin.setEncoding('utf8');
process.stdin.on('readable',()=>{
    const input = process.stdin.read().toString().trim();
    let startValue = +input.split(" ")[0];
    let iterations = +input.split(" ")[1];

    for(let i = 0; i < iterations; i++){
        if(startValue % 10 === 0){
            startValue /= 10;
        }else{
            startValue-=1;
        }
    }
    console.log(startValue);

})


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

rl.on('line', function(line) {
    var l = line.split(' ');
    var num = l[0];
    var count = +l[1];
    function ws(num, c) {
        if (c === 0) {
            console.log(num);
        } else {
            var n = (''+num).split('');
            if (n[n.length-1] == 0) {
                n[n.length-1] = ''
            } else if (n[n.length-1] == 1){
                n[n.length-1] = '0';
            } else {
                n[n.length-1] = 1;
            }
            ws(n.join(''), c-1);
        }
    }
    ws(num, count);
	rl.close();
});


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

    logic();
});

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

function output(x) {
    process.stdout.write(x);   // without auto '\n' (newline)
    //console.log(x);  // with auto '\n' (newline)
}

function logic() {
    const line = readline();

    const params = line.split(' ');
    const number = parseInt(params[0]);
    const iterations = parseInt(params[1]);

    let result = number;
    for (let i=1; i <= iterations; i++) {
        let lastNum = parseInt(String(result)[result.length-1]);
        if (lastNum > 0) {
            result--;
        }
        else {
            result /= 10;
        }
    }

    output(result);
}


let fs = require('fs');
let txt = fs.readFileSync(0, 'utf-8').split("\r\n").filter(data => {
    return data.length > 0
});
txt.shift()
for (let index = 0; index < txt.length; index ++) {
    let info=txt[index].split(" ")
    subs(info[0]*1,info[1]*1)

}
function subs(num,count){
    let tab=String(num).split("");
    while (count>0) {
        if(tab[tab.length-1]==0){
            tab.pop();
        }else{
            --tab[tab.length-1];
        }
        --count;
    }
    console.log(tab.join(""));
}


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/=10;
        }
        else{
            num-=1;
        }

    }

    return num;
}


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() {
  var [n, k] = readLine().split(" ").map(Number);
  if (n % 10 === 0) {
    for (let i = 0; i < k; i++) {
      n = n / 10;
      // console.log("n1", n);
    }
  } else {
    for (let i = 0; i < k; i++) {
      if (n % 10 === 0) {
        n = n / 10;
      } else {
        n = n - 1;
      }
    }
  }
  console.log(n);
}


"use strict";

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

// single line input
readline.on('line', line => {
    const arr = line.split(' ').map(el => Integer.parseInt(el));

  readline.close(), console.log(arr);
});


'use strict';

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

// single line input
readline.on('line', line => {
    readline.close();
    const arr = line.split(' ').map(Number);
    let n = arr[0];
    let k = arr[1];
    while (--k) {
        const rem = n % 10;
        if (rem != 0) {
            --n;
        } else {
            n /= 10;
        }
    }
    console.log(n);
});


const readline = require('readline');

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

rl.question('Provide the arguments', (answer) => {
    const argumentsArray = answer.split(' ');
    let number = argumentsArray[0];
    const times = argumentsArray[1];

    for(i = 0; i < times; i++){
        if(number % 10 == 0) {
            number /= 10;
        } else {
            number--;
        }
    }

    console.log(number);
    rl.close();
});


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


'use strict';
var debug = typeof v8debug === 'object' || /--debug|--inspect/.test(process.execArgv.join(' '));

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

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    // if(Array.isArray(inputString)) inputString = inputString.join('\n');
    inputString += inputStdin;
    // inputString = inputString.trim().split('\n').map(string => {
    //     return string.trim();
    // });

    // main();
});

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().trim().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 year = readline().trim().split('').filter(i => i).map(i => parseInt(i));
  const Year1 = [...year].join('') * 1;
  const getNextYear = (y,x, list) => {
    for(let i = y[x]; i<=9; i++) {
      if(!list.includes(i)){
        y[x] = i;
        if(x<3){
          let yy = getNextYear(y,x+1,[...list, i]);
          if(yy) {
            return yy;
          }else{
            y[x+1] = 0;
          }
        }else if(y.join('') * 1 > Year1){
          return y.join('') * 1;
        }
      }
    }
  }
  console.log(getNextYear(year,0,[]));
}


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

let currentLine = 0;
let inputString = "";

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

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

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

/******** Main function*************/

function main() {
  var n = +readLine();

  function isDistinctDigits(year) {
    var arr = ("" + year).split("");
    if (
      arr[0] !== arr[1] &&
      arr[0] !== arr[2] &&
      arr[0] !== arr[3] &&
      arr[1] !== arr[2] &&
      arr[1] !== arr[3] &&
      arr[2] !== arr[3]
    ) {
      return true;
    } else {
      return false;
    }
  }

  for (var i = n + 1; i <= 9000; i++) {
    if (isDistinctDigits(i)) {
      console.log(i);
      break;
    }
  }
}


let fs = require('fs');

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});
for (let index = 0; index < txt.length; index++) {
    doit(String(txt[index]*1+1));
}

function doit(num) {
    while (true) {
        let test=false;
        for (let i =num.length-1 ; i>0; i--) {
            if(num[i]==num[i-1]){
                test=true;
                num=String(++num);
                break;
            }

        }
        if(!test){
            break;
        }
    }
    console.log(num);

}


let fs = require('fs');

let txt = fs.readFileSync("input.txt", "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});
for (let index = 0; index < txt.length; index++) {
    doit(txt[index]*1+1);
}

function doit(num) {
    let tab = String(num).split("");
    while (true) {
        let test = true;
        for (let index = tab.length - 1; index >= 0; index--) {
            if (tab.indexOf(tab[index]) != index) {
                test = false;
                tab = String(tab.join("") * 1 + Math.pow(10, tab.length - index - 1)).split("");
                break;
            }
        }
        if (test) {
            break;
        }
    }
    console.log(tab.join(""));
}


const readline = require('readline')

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

rl.on('line', line => {
  const [a, b] = line.split(' ').map(v => parseInt(v, 10))
  solve(a, b)
})

function solve(a, b) {
 if (a == b) { console.log(0); return; }

 const m = {}
 if (b > a) {
  const t = a; a = b; b = t;
 }
 const ma = { [a]: 0 }
 const mb = { [b]: 0 }

 const qa = [[a, 0]]
 const qb = [[b, 0]]

 let min = Infinity;
 while (true) {
  if (qa.length) {
  const [aa, sa] = qa.shift()

  for (const d of [2,3,5]) {
   if (aa%d == 0) {
     const r = aa/d
     if (mb[r]) { min = Math.min(mb[r]+sa+1, min); }
     if (!ma[r]) { qa.push([r, sa+1]) }
     ma[r] = ma[r] || (sa+1);
   }
  }
 }

 if (qb.length) {

  const [bb, sb] = qb.shift()
  for (const d of [2,3,5]) {
   if (bb%d == 0) {
     const r = bb/d
     if (ma[r]) { min = Math.min(ma[r]+sb+1, min); }
     if (!mb[r]) { qb.push([r, sb+1]) }
     mb[r] = mb[r] || (sb+1);
   }
  }
 }

 if (isFinite(min)) { console.log(min); return; }

  if (!qa.length && !qb.length) { console.log(-1); return; }

 }
}


const readline = require('readline');

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

rl.on("line", (answer) => {
	rl.close();
	console.log(/[QR9]/g.test(answer) ? "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++];
}
function main() {
  const str = readLine();
  let countPlus = 0;
  const nums = str.split("").reduce((obj, char) => {
    if (char - char === 0) obj[char] = char;
    return obj;
  }, {});

  for (let i = 0; i < str.length; i++) {
    if (str[i] === "+") countPlus++;
  }

  Object.keys(nums).forEach((key) => {
    nums[key] = +nums[key] + countPlus;
  });

  if (str.includes("H") || str.includes("Q") || str.includes("9") || Object.values(nums).includes(9)) {
    console.log("YES");
  } else {
    console.log("NO");
  }
}


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

rl.on('line', (str) => {
  if (/[HQ0-9]/.test(str)) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }
});


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

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

readLine.on('close', () => {
  let str = input[0];

  for (let i = 0; i < str.length; i += 1) {
    if (str[i] === 'H' || str[i] === 'Q' || str[i] === '9' || str[i] === '+') {
      console.log('YES'); process.exit();
    }
  }

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


const readline = require('readline');

let secondLine = false;

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

let inputs = [];

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

// Read Inputs
rl.on('close', () => {
    const line1 = inputs[0].split(' ');
    const songs = inputs[1].split(' ');
    const D = parseInt(line1[1].split(' ')[0]);
    let spareTime = 0;
    let neededDurationForSongs = 0;
    for (let i = 0; i < songs.length; i++) {
        neededDurationForSongs += parseInt(songs[i]);
    }

    spareTime = (songs.length - 1) * 10;

    if (neededDurationForSongs + spareTime > D)
        return console.log(-1)

    let durationsForJokes = D - neededDurationForSongs;

    return console.log(durationsForJokes / 5)
});


"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() {
   let matrix = [];
  for(let i=0;i<5;i++){
      matrix.push(readline()
    .split("")
    .map((x) => +x));
  }

  beautifulMatrix(matrix);
}

function beautifulMatrix(matrix) {
   for (let row = 0; row < matrix.length; row++) {
    for (let column = 0; column < matrix[row].length; column++) {
      if (matrix[row][column] == 1) {
        console.log(Math.abs(2 - row) + Math.abs(2 - column));
        return Math.abs(2 - row) + Math.abs(2 - column);
      }
    }
  }
}


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', () => {

    let arr = [];
    let bestPosition = [2, 2];

    for (let i = 0; i < inputs.length; i++) {
        const subArr = inputs[i].split(' ');
        arr.push(subArr);
    }

    // Get The position of 1
    let currentPositon = [];
    for (let i = 0; i < arr.length; i++) {

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

    // Get the max number that needs minimum steps

    let minimumSteps = 0

    if (currentPositon.toString() != bestPosition.toString()) {
        const rowSteps = currentPositon[0] - bestPosition[0];
        const colSteps = currentPositon[1] - bestPosition[1];
        minimumSteps = Math.abs(rowSteps + colSteps);
    }

    console.log(minimumSteps);

})


const readline = require('readline')

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

let count = 0;
const matrix = [];

rl.on('line', line => {
    makeMatrix(line);
    count ++;
    l(count);
    if (count >= 5) {
        console.log(solution(matrix));
    }
});

function makeMatrix(line) {
    const row = line.split(' ').map(char => Number(char));
    matrix.push(row);
}

function solution(matrix) {
// Get the matrix from the input and put it into a data structure
// Count the minimum number needed to make the matrix beautiful
    const index = getIndex(matrix);
    return (Math.abs(2 - index[0]) + Math.abs(2 - index[1]));

}

// Finds and returns the index of '1'
function getIndex(matrix) {
    let x = 0, y = 0;
    for (let i = 0; i < matrix.length; i++) {
        for (let j = 0; j < matrix.length; j++) {
            if (matrix[i][j] === 1) {
                return [i, j];
            }
        }
    }
}


// Interface of codeforces.com
let stdin = process.stdin;
stdin.setEncoding('utf8');

stdin.on('line', line => {
    makeMatrix(line);
    count ++;
    if (count >= 5) {
        console.log(solution(matrix));
    }
});

function makeMatrix(line) {
    const row = line.split(' ').map(char => Number(char));
    matrix.push(row);
}

function solution(matrix) {
// Get the matrix from the input and put it into a data structure
// Count the minimum number needed to make the matrix beautiful
    const index = getIndex(matrix);
    return (Math.abs(2 - index[0]) + Math.abs(2 - index[1]));

}

// Finds and returns the index of '1'
function getIndex(matrix) {
    let x = 0, y = 0;
    for (let i = 0; i < matrix.length; i++) {
        for (let j = 0; j < matrix.length; j++) {
            if (matrix[i][j] === 1) {
                return [i, j];
            }
        }
    }
}


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
	}

	console.log(m)
	console.log(m[1][4])

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


// https://codeforces.com/problemset/problem/263/A

function main(stdin) {
  const matrix = stdin.map(row => row.split(' ').map(Number))
  let y = 0; let x = 0

  while(matrix[y][x] !== 1)
    if(x < 5) { x++ }
    else { x = 0; y++ }

  process.stdout.write(Math.abs(((y - 2) * -1) + (x - 2)) + '')
}

// Handle standard input
process.stdin.resume()
process.stdin.setEncoding('utf-8')

let inputString = ''

process.stdin.on('data', (inputStdin) => inputString += inputStdin)
process.stdin.on('end', () =>
  main(inputString.trim().split('\n').map(s => s.trim())))


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

const input = [];
readLine.on('line', line => input.push(line));
const matrix = () => {
    let oneStringRow;
    let oneColumn;
    let steps;
    for (let i = 0; i < input.length; i++) {
        if (input[i].includes('1')) {
            oneStringRow = i;
            oneColumn = input[i].indexOf('1') / 2;
        }
    }
    steps = Math.abs(2 - oneStringRow) + Math.abs(2 - oneColumn);
    console.log(steps);
    readLine.on('close', matrix);

};


var stdin = process.openStdin();

stdin.addListener("data", function(d) {
    const arr = d.toString().trim().split(" ");
    console.log(findg(parseInt(arr[0]), parseInt(arr[1])));
  });

 function findg(n, m){
    if(n === m){
        return 0;
    } else if(m === 0){
        return 1;
    }
    m--;
    let gcount  = 1;
    for(let i = 0; i < m; i++){
        if(n === 0 || n === 1){
            gcount--;
        } else {
            gcount++;
            n-=2;
        }
    }
    return gcount;
 }


const readline = require('readline');

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

var SumOfBase = function (N, base) {
    ans = 0;
    while (N != 0) {
        ans += N % base;
        num = parseInt(N / base);
    }
    return ans;
}

var GCD = function (a, b) {
    if (a == 0)
        return b;
    return GCD(a, b % a);
}

rl.on('line', (input) => {
    var n = parseInt(input);
    var ans = 0;

    for (let i = 2; i < n; i++)
        ans += SumOfBase(n, i);

    console.log("%d/%d",ans / GCD(ans, n - 2), n - 2 / GCD(ans, n - 2));
    rl.close();
});


const readline = require("readline");

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

var counter = 0;
var n = 0;

rl.on("line", input => {
  n = parseInt(input);
  for (var i = 2; i < n; i++) {
    var item = n;
    while (n != 0) {
      counter += n % i;
      n = parseInt(n / i);
    }
    n = item;
  }
  console.log(counter + "/" + (n - 2));
  rl.close();
});


function main() {
    // write code here:

}

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,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  let ans = [0, 1, 5];
  let inc = 3;

  for (let i = 3; i <= +d; i++) {
    inc += 2;
    let v = inc * inc - i * 4;
    ans[i] = v;
  }

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


const readline = require('readline');

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

rl.on('line', (employees) => {
  let teamLeaders = ways = 0;
  for (let index = 1; index < employees; index++) {
    if (teamLeaders >= employees) {
      console.log(ways);
      return rl.close();
    } else if ((employees - index) % (teamLeaders + index) === 0) {
      teamLeaders += index;
      employees -= index;
      ways += 1;
      index -= 1;
    }
  }
  console.log(ways);
  return rl.close();
});


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

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

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

  for (let i = 1; i < n/2; i += 1) {
    let ost = n - i;

    if (ost % i === 0) answer += 1;
  }

  console.log(answer)
});


const readline = require('readline');

let inputs = [];

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

// Read Inputs
rl.on('line', inputLine => {
    const n = parseInt(inputLine);

    if (n >= 0) {
        return console.log(n)
    } else {
        let digits = Math.abs(n).toString().split('');
        const lastNum = digits[digits.length - 1];
        const numBeforeLast = digits[digits.length - 2];
        if (lastNum > numBeforeLast) {
            digits = digits.splice(0, digits.indexOf(lastNum))
        } else {
            const temp = digits.slice(0);
            const idxBeforeLast = temp.length - 2;
            temp.splice(idxBeforeLast, 1)
            return console.log(`-${temp.join('')}`)
        }

        return console.log(`-${digits.join('')}`)

    }

});


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

rl.on('line', (d) => {
  if (d === '-10') {
    console.log('0');
    return;
  }

  const n = [...d];
  const a = +d;
  const b = +(n.slice(0, n.length - 2).join('') + n.slice(n.length - 1).join(''));
  const c = +(n.slice(0, n.length - 1).join(''));
  const ans = Math.max(a, b, c);

  console.log(ans);

});


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

rl.on("line", (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));
      }
    }
  }
});

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


//96A
const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
rl.question('', (answer) => {
    rl.close()
    let team1 = 0
    let team2 = 0
    let array = answer.split("")
    let i = 1
    array.forEach(function(player) {

        if (player == 0) {
            team2 = 0
            team1++
            if (team1 == 7) {
                if (!i == 0) {
                    console.log("YES")
                    i == 0

                }
            }
        } else {
            team2 ++
            team1 = 0
            if (team2 == 7) {
                if (!i == 0) {
                    console.log("YES")
                    i==0
                }

            }
        }
    })
    if (!i == 0) {
        console.log("NO")
    }

});


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

readline.question("",(ans)=>{
    var teamA=0; //team 0
    var teamB=0; //team 1
    var lastWord=ans[0];
    for (let i = 1; i < ans.length; i++) {
        const word=ans[i];
        word!=lastWord
        ?   (ResetTeam(),word==0?++teamA:++teamB)
        :   word==0
            ?  ++teamA
            :   ++teamB;

        lastWord=word;

        if(teamA>=7||teamB>=7){
            break;
        }
    }

    teamA>=7||teamB>=7
    ?   console.log("YES")
    :   console.log("NO");
    readline.close();

    function ResetTeam(){
        teamA=0;
        teamB=0;
    }
})


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 str = readLine();
  let [count0, count1] = [0, 0];
  let [max0, max1] = [0, 0];

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

    if (num === 0) {
      count0++;
      max1 = Math.max(count1, max1);
      count1 = 0;
    } else {
      count1++;
      max0 = Math.max(count0, max0);
      count0 = 0;
    }
  }
  if (max0 >= 7 || max1 >= 7) console.log("YES");
  else console.log("NO");
}


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;
  let ans = 'NO';

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

      count = 1;
    }
  }

  console.log(ans);

  c++;
});


//var print = require('lol-io').print
//var readline = require('lol-io').readline

let input = readline();
let counter = 0;
let result = "NO";

for (let i = 0; i < input.length; i++) {
    if (input[i] === input[i + 1]) {
        counter++;
    } else if (input[i] !== input[i + 1]) {
        counter = 0;
    }

    if (counter === 7) {
        result = 'YES';
        break;
    } else {
        result = 'NO';
    }
}

print(result);


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

readline.on("line", line => {
    let counter = 0;
    let result = "NO";
    let input = line;
    for (let i = 0; i < input.length; i++) {
        if (input[i] === input[i + 1]) {
            counter++;
        } else if (input[i] !== input[i + 1]) {
            counter = 0;
        }

        if (counter === 7) {
            result = 'YES';
            break;
        } else {
            result = 'NO';
        }
    }
    console.log(result);
});


process.stdin.resume()
process.stdin.setEncoding('utf-8')
let inputs = ""
process.stdin.on('data', rawData => inputs += rawData)
process.stdin.on('end', _ => {
    inputs = inputs.trim().split('').map(line => parseInt(line))
    main()
})
function main() {
    let playersNumber = 0
    let team = 0
    let shouldExit = false
    let result = "NO"
    inputs.map(i => {
        if (playersNumber === 7) {
            result = "YES"
            shouldExit = true
            return;
        }
        if (shouldExit)
            return;
        if (i !== team){
            team = i
            playersNumber = 0
        }
        playersNumber++
    })
    console.log(result)
}


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

process.stdin.on('data', (input) => {
  const isDanger = () => {
    let team, count;

    for (let i = 0; i < input.length; i++) {
      team = input[i];
      count = 1;

      while (input[++i] === team && i < input.length - 1) count++;

      if (count > 6) return 'YES';
    }

    return 'NO';
  };

  process.stdout.write(isDanger());
});


//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]);
  		}
  	}
  	if(!isOK){
  		map[key.length] = [list[i]];
  	}
  }
  myout(Object.keys(map).length);
}


var line_number = 0
const cs = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

var lines = {}
cs.on("line", (input) => {
    if (input == '') {
        cs.close()
    }
    lines[line_number] = input.split(" ")
    line_number += 1
}).on('close', () => {
    main()
    process.exit()
})

function isOp(str) {
    return str.length === 1 && str.match(/[<=>]/)
}
function isChr(str) {
    return str.length === 1 && str.match(/[a-z]/i)
}
function isInt(str) {
    return str.length === 1 && !isNaN(str)
}

function print(str) {
    console.log(str)
}

function predict(test) {
    let op=''
    let ops=[]
    let opVariables = [];
    let limits = []
    for (let t of test) {
        // console.log(t);
        for(let i=0; i<t.length; i++) {
            if ( isOp(t[i]) ) {
                op = t[i]
                if ( isOp(t[i+1]) ) {
                    op += t[i+1]
                    i += 1
                }
                ops.push(op)
                op=''
            }
            else if (isChr(t[i])) {
                // console.log(t[i])
                op = t[i]
                for (var j = i + 1; j<t.length; j++) {
                    if (isChr(t[j]) || isInt(t[j])) {
                        op += t[j]
                        i = j
                    }
                    else
                        break
                }
                opVariables.push(op)
                op = ''
            } else {
                if ( i == 0 || (i>0 && isOp(t[i-1])) ) {
                    op = t[i]
                    let j = i + 1
                    for(; j<t.length; j++) {
                        if ( isInt(t[j]) ) {
                            op += t[j]
                            i = j
                        }
                        else
                            break
                    }
                    limits.push(op);
                    op = ''
                }
            }
        }
    }

    let min = limits[0]
    let max = limits[1]

    let pvs = ops.map((o,i) => [o, opVariables[i]])

    for(let pv of pvs) {
        if (pv[1] == undefined) {
            pv[1] = max
        }
        // print(`${min} ${pv[0]} ${pv[1]} ?`)
        if (eval(`${min}${pv[0]}${pv[1]}`)) {
            // print(` ${min} ${pv[0]} ${pv[1]} true`)
            min = pv[1]
        } else {
            print("input error");
            process.exit();
        }
    }
}

var m;
var n;
function main() {
    m = parseInt(lines[0][0], 10)
    n = parseInt(lines[0][1], 10)

    predict(["1<=m<n<=16"])
    number = (m*n)/2
    print(number)
}


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

cs.prompt()

var lines = {}
cs.on("line", (input) => {
    if (input == '') {
        cs.close()
    }
}).on('close', () => {
    main()
    process.exit()
})

function isOp(str) {
    return str.length === 1 && str.match(/[<=>]/)
}
function isChr(str) {
    return str.length === 1 && str.match(/[a-z]/i)
}
function isInt(str) {
    return str.length === 1 && !isNaN(str)
}

function print(str) {
    console.log(str)
}

function predict(test) {
    let op=''
    let ops=[]
    let opVariables = [];
    let limits = []
    for (let t of test) {
        // console.log(t);
        for(let i=0; i<t.length; i++) {
            if ( isOp(t[i]) ) {
                op = t[i]
                if ( isOp(t[i+1]) ) {
                    op += t[i+1]
                    i += 1
                }
                ops.push(op)
                op=''
            }
            else if (isChr(t[i])) {
                // console.log(t[i])
                op = t[i]
                for (var j = i + 1; j<t.length; j++) {
                    if (isChr(t[j]) || isInt(t[j])) {
                        op += t[j]
                        i = j
                    }
                    else
                        break
                }
                opVariables.push(op)
                op = ''
            } else {
                if ( i == 0 || (i>0 && isOp(t[i-1])) ) {
                    op = t[i]
                    let j = i + 1
                    for(; j<t.length; j++) {
                        if ( isInt(t[j]) ) {
                            op += t[j]
                            i = j
                        }
                        else
                            break
                    }
                    limits.push(op);
                    op = ''
                }
            }
        }
    }

    let min = limits[0]
    let max = limits[1]

    let pvs = ops.map((o,i) => [o, opVariables[i]])

    for(let pv of pvs) {
        if (pv[1] == undefined) {
            pv[1] = max
        }
        // print(`${min} ${pv[0]} ${pv[1]} ?`)
        if (eval(`${min}${pv[0]}${pv[1]}`)) {
            // print(` ${min} ${pv[0]} ${pv[1]} true`)
            min = pv[1]
        } else {
            print("input error");
            process.exit();
        }
    }
}

var m;
var n;
function main() {
    m = parseInt(lines[0][0], 10)
    n = parseInt(lines[0][1], 10)

    predict(["1<=m<n<=16"])
    number = (m*n)/2
    print(number)
}


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

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

	rl.close();
});

//M N
let DominoPiling = (line) => {
	let M = line.charAt(0) * 1;
	let N = line.charAt(2) * 1;
	// 2*1
	let num1 = M % 2 === 0 ? M / 2 : (M - 1) / 2;
	if (num1 === M / 2) {
		console.log(num1 * N);
	} else {
		console.log(num1 * N + Math.floor(N / 2));
	}
};


// http://codeforces.com/problemset/problem/977/A
module.exports = solve;
function solve(line) {
    let [a, b] = line.split(' ').map(n => parseInt(n, 10));
    return ~~(a * b / 2);
}

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

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


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

// read each line
rl.on("line", (lineInput) => {
  let params = lineInput.split(" ");
  Math.floor((params[0] * params[1]) / 2);
});

// when all file readed
rl.on("close", () => {});


if (process.argv[2] === "test") {
  solve(["3 7"]);
} else {
  let i = "";
  process.stdin.on("data", (c) => (i += c));
  process.stdin.on("end", () => {
    const { EOL } = require("os");
    const lines = i.split(EOL);

    solve(lines);
  });
}

function solve(lines) {
  const [m, n] = lines[0].split(" ");
  console.log(Math.ceil((m * n) / 2));
}


'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 input1 = readline().split(' ');
  let m = parseInt(input1[0]);
    let n = parseInt(input[1]);

    maxNumDominoes(m, n)
};

function maxNumDominoes(n, m){

  console.log(Math.floor(n * m ) / 2)
}


'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 input1 = readline().split(' ');
  let m = parseInt(input1[0]);
    let n = parseInt(input1[1]);

     maxNumDominoes(m, n)
};

function maxNumDominoes(n, m){

  console.log(Math.floor(n * m ) / 2);
}


//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 a = one[0];
  var b = one[1];
  var c = one[2];
  var output = a * 2 + Math.min(b, c) * 2;
  if(b != c){
    output++;
  }
  myout(output);
}


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStd => inputString += inputStd);
process.stdin.on('end', () => {
    inputString = inputString.trim().split('\n').map(str => str.trim());
    main();
});
let readLine = () => inputString[currentLine++];

function solve(){
    let a,b, ans = "";
    a = readLine();
    b = readLine();
    for(let i = 0; i < a.length; i++){
        if(a[i] === b[i])
            ans = '0' + ans;
        else ans = '1' + ans;
    }
    console.log(ans);
}

function main(){
    solve();
}


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 === '1' || s2[i] === '1' ? '1' : '0'));
	console.log(res.join(''));
}


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}

function main() {
    let firstNumberString = readLine();
    let secondNumberString = readLine();
    let finalStringArray = [];
    for (let i = 0; i < firstNumberString.length; i++) {
        if (firstNumberString[i] !== secondNumberString[i]) {
            finalStringArray.push('1');
        } else {
            finalStringArray.push('0');
        }
    }
    let finalString = finalStringArray.map(Number);
    let finalNumber = finalString.join('');
    console.log(finalString);
}


// 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 num = Number('0b' + inputs[0].trim() ^ '0b' + inputs[1].trim()).toString(2);
    let zeros = inputs[0].trim().length - num.length;
    num = '0'.repeat(zeros) + num;
    return num.toString();
}


var data = [];

data.push(readline());

function sum(n) {
    return n.split('').map(function (d) {
        return parseInt(d);
    }).reduce(function (s, d) {
        return s + d;
    });
}

function solve() {
    var n1 = data[0];
    var s1 = sum(n1);
    var first = parseInt(n1[0]) - 1;
    var l = n1.length - 1;
    var newN = '9'.repeat(l);
    if (first !== 0) {
        newN = first + newN;
    }
    var s2 = sum(newN);
    print(s2 > s1 ? newN : n1);
}

solve();


var data = [];

data.push(readline());

function sum(n) {
    return n.split('').map(function (d) {
        return parseInt(d);
    }).reduce(function (s, d) {
        return s + d;
    });
}

function solve() {
    var n1 = data[0];
    if (n1.length === 1) {
        return print(n1);
    }
    var s1 = sum(n1);
    var first = parseInt(n1[0]) - 1;
    var l = n1.length - 1;
    var newN = '9'.repeat(l);
    if (first !== 0) {
        newN = first + newN;
    }
    var s2 = sum(newN);
    print(s2 > s1 ? newN : n1);
}

solve();


var x = +readline();

function findMax(n) {
	var digits = ("" + n).split(""),
		currentSum = getDigitsSum(digits),
		nextNumber = +((digits[0] - 1) + (new Array(digits.length)).join("9")),
		nextSum = getDigitsSum(nextNumber);

	if(currentSum > nextSum) return n;
	if(currentSum < nextSum) return nextNumber;
	return Math.max(n, nextNumber);
}

function getDigitsSum(digits) {
	if(!Array.isArray(digits)) digits = ("" + digits).split("");
	return digits.reduce(function (sum, n) {
		return sum + 1*n;
	}, 0);
}

print(findMax(x));


const readline = require('readline');

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

var check = function (s) {
    var n = s.length;
    if (n == 0 || n > 16)
        return false;
    console.log("inside function s=%s n=%d",s,n);
    for (let i = 0; i < n; i++) {
        if (!(s[i] >= 'A' && s[i] <= 'Z' ||
            s[i] >= 'a' && s[i] <= 'z' ||
            s[i] >= '0' && s[i] <= '9' ||
            s[i] == '_'))
            return false;
    }
    return true;
}

var CheckHostName = function (HostName) {
    var N = HostName.length
    if (N == 0 || N > 32)
        return false;

    var Host = HostName.split(".");
    for (let i = 0; i < Host.length; i++) {
        if (!check(Host[i]))
            return false;
    }

   /*
    HostName.split('.').forEach(element => {
        if (!check(element))
            return false;
    });
    */

    return true;
}

rl.on('line', (input) => {
    let IsUser = false, IsHost = false, IsResource = false;
    let AtIndex = input.indexOf('@');
    if (AtIndex != -1) {
        var UserName = input.substring(0, AtIndex);
        IsUser = check(UserName);
        var SlashIndex = input.indexOf("/");
        /*
        if (SlashIndex != -1)
            var HostName = input.substring(AtIndex + 1, SlashIndex - AtIndex - 1);
        else
           var HostName = input.substring(AtIndex + 1);
           */
        var HostName = (SlashIndex != -1)? input.substring(AtIndex + 1, SlashIndex): input.substring(AtIndex + 1);
        IsHost = CheckHostName(HostName);
        if (SlashIndex == -1)
            IsResource = true;
        else{
            var Resource = input.substring(SlashIndex + 1);
            IsResource = check(Resource);
        }
    }
    console.log("input=%s  IsUser=%s  IsHost=%s  IsResource=%s",input, IsUser , IsHost , IsResource)
    console.log((IsUser && IsHost && IsResource) ? "YES" : "NO");
    rl.close();
});


const readline = require('readline');

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

function check(s) {
    let sLen = s.length;
    if (sLen == 0 || sLen > 16)
        return false;

    for (let i = 0; i < sLen; i++) {
        if (!(s[i] >= 'a' && s[i] <= 'z' ||
            s[i] >= 'A' && s[i] <= 'Z' ||
            s[i] >= '0' && s[i] <= '9' ||
            s[i] == '_')) return false;
    }

    return true;
}

function checkHost(hostName) {
    let hostLen = hostName.length;
    if (hostLen == 0 || hostLen > 32)
        return false;
    var tokens = hostName.split('.');
    for (let i = 0; i < tokens.length; i++)
        if (!check(tokens[i])) return false;

    return true;
}

var isUser = false, ishost = false, isResource = false;
rl.on('line', (input) => {

    let atIndx = input.indexOf('@');
    if (atIndx != -1) {
        let userName = input.substring(0, atIndx);
        isUser = check(userName);
        let slashIndx = input.indexOf('/');
        let hostName = (slashIndx != -1) ? input.substring(atIndx + 1, slashIndx) : input.substring(atIndx);
        ishost = checkHost(hostName);

        if (slashIndx == -1) isResource = true;
        else {
            let resource = input.substring(slashIndx + 1);
            isResource = check(resource);
        }

    }

    console.log((isUser && ishost && isResource) ? "YES" : "NO");
    rl.close();
});


var n = new Big(tmp[0]);
var m = new Big(tmp[1]);
if(n.lte(m)) {
  print(n);
} else {
  n.RM = 3;
  print(n.minus(m).minus(1).times(8).plus(9).sqrt().times(0.5).minus(1.5).round().plus(1).plus(m).toString());
}


var line_number = 0;
const cs = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

var lines = {};
cs.on("line", (input) => {
  if (input == "") {
    cs.close();
  }
  lines[line_number] = input.split(" ");
  line_number += 1;
}).on("close", () => {
  main();
  process.exit();
});

function isOp(str) {
  return str.length === 1 && str.match(/[<=>]/);
}
function isChr(str) {
  return str.length === 1 && str.match(/[a-z]/i);
}
function isInt(str) {
  return str.length === 1 && str.match(/[0-9*]/);
}

function print(str) {
  console.log(str);
}

function exit(status = 0) {
  process.exit(status);
}

function predict(test) {
  let op = "";
  let ops = [];
  let opVariables = [];
  let limits = [];
  for (let t of test) {
    // console.log(t);
    for (let i = 0; i < t.length; i++) {
      if (isOp(t[i])) {
        op = t[i];
        if (isOp(t[i + 1])) {
          op += t[i + 1];
          i += 1;
        }
        ops.push(op);
        op = "";
      } else if (isChr(t[i])) {
        // console.log(t[i])
        op = t[i];
        for (var j = i + 1; j < t.length; j++) {
          if (isChr(t[j]) || isInt(t[j])) {
            op += t[j];
            i = j;
          } else break;
        }
        opVariables.push(op);
        op = "";
      } else {
        if (i == 0 || (i > 0 && isOp(t[i - 1]))) {
          op = t[i];
          let j = i + 1;
          for (; j < t.length; j++) {
            if (isInt(t[j])) {
              op += t[j];
              i = j;
            } else break;
          }
          limits.push(op);
          op = "";
        }
      }
    }
  }

  let min = limits[0];
  let max = limits[1];

  let pvs = ops.map((o, i) => [o, opVariables[i]]);

  for (let pv of pvs) {
    if (pv[1] == undefined) {
      pv[1] = max;
    }
    // print(`${min} ${pv[0]} ${pv[1]} ?`)
    if (eval(`${min}${pv[0]}${pv[1]}`)) {
      // print(` ${min} ${pv[0]} ${pv[1]} true`)
      min = pv[1];
    } else {
      print("input error");
      exit();
    }
  }
}

var n;
function main() {
  x = BigInt(lines[0][0])
  predict(["1<=x<=10**15"]);

  let S=0,e=0,o=0
  if (x%2n == 0) {
    e = (x*x+2n*x)/4n
    o = (x*x)/4n
  }
  else
  {
    e = ((x-1n)*(x-1n)+2n*(x-1n))/4n
    o = ((x+1n)*(x+1n))/4n
  }

  print(e-o)

}


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

let ans = 0;

rl.on('line', (d) => {
  for (let i = 1; i <= +d; i++) {
    if (i % 2 !== 0) {
      ans -= i;
    }
    else {
      ans += i;
    }
  }

  console.log(ans);
});


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

let ans = 0;

rl.on('line', (d) => {
  let n = +d;

  if (n % 2 === 0) {
    ans = n / 2;
  }
  else {
    ans = - (n / 2);
  }

  console.log(ans);
});


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

rl.question('', (line) => {
  n = parseInt(line)
  main()
})

let wynik = 0

function main() {
  for (let i = 1; i<=n; i++) {
    if (i % 2 === 0){
      wynik += i
    } else
      wynik += -1*i
  }
  console.log(wynik)
  rl.close()
}


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 = parseInt(readLine());
  let sum = 0
  for(let i = 1; i <= n; i++) {
    if(i % 2 === 0) {
        sum += i
    } else if(i % 2 !== 0) {
        sum -= i
    }
  }

  console.log(sum)
}


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 x = parseInt(readLine());
    let odd = 0
    let even = 0
    let tEven = 0
    let tOdd = 0

    if (x % 2 === 0) {
        tEven = parseInt(x / 2)
        tOdd = parseInt(x / 2)
    } else if (x % 2 !== 0) {
        tOdd = parseInt(x / 2) + 1
        tEven = parseInt(x / 2)
    }

    odd = seriesSum(tOdd, -1, -2)
    even = seriesSum(tEven, 2, 2)

    console.log(even + odd)
}

function seriesSum(n, a, d) {
    return (n * ((2 * a) + ((n - 1) * d))) / 2
}


let fs = require('fs');

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});

for (let i = 0; i < txt.length; i++) {
    doit(txt[i]*1);
}

function doit(n) {
    let pnt=-1,sum=0;
    for (let i = 1; i <= n; i++) {
        sum+=i*pnt;
        pnt*=-1;
    }
    console.log(sum);

}


let fs = require('fs');

let txt = fs.readFileSync("input.txt", "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});

for (let i = 0; i < txt.length; i++) {
    doit(txt[i]*1);
}

function doit(n) {
    if(n%2===0){
        console.log(n/2);
    }else{
        console.log((n+1)/2*-1);
    }

}


// 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();
    let sum = 0;
    for (let i = 1; i < inputs; i++) {
        sum += (i % 2 === 0 ? i : -i);
    }
    sum += Math.pow(-1, inputs) * inputs;
    return sum.toString();
}


'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;
    for (var i = 1; i <= n; i++) {
        ans += Math.pow(-1, i) * i
    }
    console.log(ans);
}


const readline = require('readline');

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

rl.on('line', function(line){
	const b = parseInt(line);
	let counter = 0;
	for (let i = 1; i <= b / 2; i++) {
		if (b % i === 0) { counter++ }
	}
	console.log(counter + 1);
	rl.close();
});


const readline = require('readline');

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

rl.on('line', function(line){
	const b = parseInt(line);
	let counter = 0;
	const sqrt = Math.sqrt(b)
	for (let i = 2; i < sqrt; i++) {
		if (b % i === 0) { counter += 2; }
	}
	if (sqrt % 1 === 0) { counter++; }
	console.log(counter + 2);
	rl.close();
});


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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  const n = parseInt(arr)
  const sq = Math.sqrt(n)
  let k = 0
  for(let i = 1; i < sq; i++) {
    if(n % i == 0) {
      if(n / i == i) k ++
      else k +=2
    }
  }
  console.log(k)

})


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

var idx = 0;

var line1 = "";
var line2 = "";

rl.on("line", (theLine) => {
    if (idx == 0)
        line1 = theLine.toString().toUpperCase()
    else
        line2 = theLine.toString().toUpperCase();
    idx++
    if (idx > 1)
    {
        rl.close();
        console.log(line1 < line2 ? "-1":(line1 === line2 ? "0": "-1"));
    }
 }
);


const stdin = process.openStdin();
let n;
let i = 0;
let output = 0;

process.stdin.on('data', function (chunk) {
  lines = chunk.toString().split('\n');
  lines = lines.map(a => a.trim().toLowerCase());
  for (let i = 0; i < lines[0].length; i+= 1) {
    if (lines[0].charAt(i) > lines[1].charAt(i)) { output += 1; }
    if (lines[0].charAt(i) < lines[1].charAt(i)) { output -= 1; }
  }
  console.log(output);
});


'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 main() {
    let s1 = readLine().toLowerCase();
    let s2 = readLine().toLowerCase();
    let ans1 = s1.split('').reduce((sum, value) => {
        return sum + value.charCodeAt(0);
    }, 0)

    let ans2 = s2.split('').reduce((sum, value) => {
        return sum + value.charCodeAt(0);
    }, 0)
    if (ans1 < ans2) {
        console.log(-1);
    } else if (ans1 > ans2)
        console.log(1);
    else if (ans1 == ans2)
        console.log(0);
}


const readline = require("readline");

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

rl.question("", (firstLine) => {
  const [n, k] = firstLine.split(" ").map((numStr) => parseInt(numStr));

  rl.question("", (scopeListString) => {
    let result = 0;
    const scopeList = scopeListString
      .split(" ")
      .map((numStr) => parseInt(numStr));
    const scopesOfWinners = scopeList.slice(0, k);

    if (scopesOfWinners[0] > 0) {
      const scopesOfAdditionalParticipans = scopeList.slice(k);

      scopesOfAdditionalParticipans.forEach((scope) => {
        if (scope !== scopesOfWinners[scopesOfWinners.length - 1]) {
          return;
        }
        scopesOfWinners.push(scope);
      });

      result = scopesOfWinners.length;
    }

    console.log(result);
    rl.close();
  });
});


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", () => {
  const array = splitAndParseInt(input[0])
  const items = splitAndParseInt(input[1])
  const length = array[0];
  const max = array[1]
  let answer = 0;
  for(let i = 0; i <= length; i++){
    if(items[i] > max){
      answer++;
    }
  }
  console.log(answer)
});


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

let input = [];

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

rl.on("close", () => {
  console.log(solution(input[0].split(" "), input[1]));
});

const solution = ([n, k], numbers) => {
  let res = 0;
  numbers = numbers.split(" ").map((num) => parseInt(num));
  n = parseInt(n);
  k = parseInt(k);
  for (let i = 0; i < n; i++) {
    if (numbers[i] >= numbers[k]) {
      res += 1;
    } else {
      break;
    }
  }
  return res;
};


// Generated by CoffeeScript 2.5.1
var lines, mainAux, print, readline, rl, rli, write;

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

print = console.log;

write = function(...args) {
  return process.stdout.write(args.join(' '));
};

lines = [];

rl.on('line', function(line) {
  return lines.push(line);
});

rl.on('close', main);

rli = 0;

readline = function() {
  return lines[rli++];
};

mainAux = function() {
  var ff, finishers, k, n, passing;
  [n, k] = readline().split(' ');
  finishers = readline().split(' ');
  passing = parseInt(finishers[k]);
  ff = finishers.filter(function(f) {
    return f > 0;
  }).filter(function(f) {
    return f >= passing;
  });
  return print(ff.length);
};

function main() {
  return mainAux();
};

//# sourceMappingURL=ith-place-finishers.js.map


'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(String(main(inputString)));
  process.exit();
});

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

const main = inputArray => {
  const [
    numberOfParticipants,
    numberOfAdvancingScores,
  ] = inputArray[0].split(' ');
  const participantScores = inputArray[1].split(' ');
  if (numberOfAdvancingScores === numberOfParticipants)
    return participantScores.filter(score => !!score).length;

  const winners = participantScores.slice(0, numberOfAdvancingScores - 1);
  const lastWinningScore = winners[winners.length - 1];
  if (lastWinningScore === '0')
    return winners.filter(score => score !== '0').length;
  if (participantScores[numberOfAdvancingScores] !== lastWinningScore)
    return winners.length;
  for (let i = winners.length; i < participantScores.length; i += 1) {
    if (participantScores[i] === lastWinningScore) {
      winners.push(lastWinningScore);
    } else {
      break;
    }
  }

  return winners.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.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

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

function main() {
  let inp = readline().split(" ");

  let n = Number(inp[0]) || 0;
  let k = Number(inp[1]) || 0;

  let out = 0;
  if (n > k) {
    let scores = readline().split(" ");
    for (let i = 0; i < scores.length; i++) {
      if (Number(scores[i]) >= Number(scores[k])) {
        if (Number(scores[i])> 0)
          out++
      } else {
        break;
      }
    }
  }
  console.log(out)

}


const readline = require('readline');

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

let lines = [];
rl.on('line', (line) => {
    lines.push(line);
}).on('close', () => {
  const [ln, c] = lines[0].split(' ');
  const us = lines[1].split(' ').filter(v => +v > +c);

  process.stdout.write(`${us.length}\n`);
});


function main() {
    // write code here:
    var arr = stdin[0].match(/[a]/gi);
    var sLen = stdin[0].length;
    var aLen = arr.length;
    console.log(aLen > sLen / 2 ? sLen : aLen + 1);
}

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').createInterface({
  input: process.stdin,
  output: process.stdout,
});

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

readLine.on('close', () => {
let charA = input[0].match(/(a)/g)
charA = charA ? charA.length : 1
const allChars = input[0].length
const anyCars = allChars - charA
let _result = 0
if (anyCars >= charA)
  _result = (charA * 2) - 1
console.log(_result)
})


//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 s = next();
  var count = 0;
  for(var i = 0; i < s.length; i++){
    count += (s[i] == 'a') ? 1 : 0;
  }
  if(count < s.length / 2){
    myout(count * 2 - 1);
  }else{
    myout(s.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(x - a);
  }
  else {
    console.log(str.length);
  }
});


let input = [];

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

RL.on('line', (line) => {
    let count_a = 0; [...line].forEach( i => {if(i === 'a') count_a++} );
    console.log(count_a)
    if(count_a > line.length - count_a)
        console.log(line.length);
    else
        console.log( line.length - ( line.length-count_a - count_a - 1) )
});

RL.on('close', () => {
});


// https://codeforces.com/problemset/problem/596/A
// Big O:
// Time complexity:
// Space complexity:

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

let numberOfVertices;
let vertices = [];
rl.on('line', (input) => {
    if (!numberOfVertices) {
        numberOfVertices = parseInt(input);
        return;
    }

    const verticesArray = input.split(" ").map(Number)
    const x = verticesArray[0];
    const y = verticesArray[1];
    vertices.push({ x, y });

    if (vertices.length === numberOfVertices) {
        console.log(findRectangleArea(numberOfVertices, vertices));
        rl.close();
    }

});

// Problem
function findRectangleArea(numberOfVertices, vertices) {
    if (numberOfVertices === 1) {
        return -1;
    }

    if (numberOfVertices === 2) {
        return findRectangleAreaWithTwoVertices(vertices);
    }

    // if (numberOfVertices === 3) {
    return findRectangleAreaWithThreeVertices(vertices);
    // }

    // return 0;
}

function findRectangleAreaWithTwoVertices(vertices) {
    const firstVertex = vertices[0];
    const secondVertex = vertices[1];
    const x1 = firstVertex.x;
    const x2 = secondVertex.x;
    const y1 = firstVertex.y;
    const y2 = secondVertex.y;

    if (x1 === x2) {
        return x1 * Math.abs(y1 - y2);
    } else if (y1 === y2) {
        return y1 * Math.abs(x1 - x2);
    } else {
        return Math.abs(x1 - x2) * Math.abs(y1 - y2);
    }
}

function findRectangleAreaWithThreeVertices(vertices) {
    const firstVertex = vertices[0];
    const secondVertex = vertices[1];
    const thirdVertex = vertices[2];
    const x1 = firstVertex.x;
    const x2 = secondVertex.x;
    const x3 = thirdVertex.x;
    const y1 = firstVertex.y;
    const y2 = secondVertex.y;
    const y3 = thirdVertex.y;

    const y = y1 === y2 ? Math.abs(y1 - y3) : Math.abs(y1 - y2);
    const x = x1 === x2 ? Math.abs(x1 - x3) : Math.abs(x1 - x2);

    return x * y;
}


'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++].split(' ');
}

function readInt(s) {
    return parseInt(s, 10);
}

function readIntArray(a) {
    return a.map(e => parseInt(e, 10));
}

function solve(n) {
    let a = [0, 1, 2, 0, 2, 1, 0];
    let max = 0;
    for (let i = 0; i < 7; i++) {
        let korm = n.slice(0);
        let days = 0;
        let ok = true;
        for (let j = i; j < 7; j++) {
            if (korm[a[j]] > 0) {
                korm[a[j]]--;
                days++;
            } else {
                ok = false;
                break;
            }
        }
        if (!ok) {
            if (days > max) max = days;
            continue;
        }
        let weeks = Math.min(Math.floor(a[0] / 3), Math.floor(a[1] / 2), Math.floor(a[2] / 2));
        days += weeks * 7;
        korm[0] -= 3 * weeks;
        korm[1] -= 2 * weeks;
        korm[2] -= 2 * weeks;
        for (let j = 0; j < 7; j++) {
            if (korm[a[j]] > 0) {
                korm[a[j]]--;
                days++;
            } else {
                break;
            }
        }
        if (days > max) max = days;
    }
    return max;
}

function main() {

    const a = readIntArray(readLine());

    let result = solve(a);
    console.log(result);
}


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

rl.on("line", (line) => {
  let params = line.split(" ");
  if ((input[0] * input[1]) % 2 == 0) console.log("Malvika");
  else console.log("Akshat");
});
rl.on("close", () => {});


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

rl.on("line", (line) => {
  let params = line.split(" ");
  let smaller = params[0];
  // ger min
  if (params[1] <= params[0]) smaller = params[1];
  if (smaller % 2 == 0) console.log("Malvika");
  else console.log("Akshat");
});

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


let fs = require('fs');

let txt = fs.readFileSync(0, "utf-8").split("\n").filter(data => data.length > 0);
for (let i = 0; i < txt.length; i++) {
    let info = txt[i].split(" ").filter(data => data.length > 0).map(data => data * 1);
    doit(info[0], info[1]);
}

function doit(x, y) {
    let player = 1;
    let grid = new Array(y).fill(0);
    grid.forEach((data, index) => {
        grid[index] = new Array(x).fill(true);
    });
    while (true) {
        let test = true;
        for (let i1 = 0; i1 < y; i1++) {
            for (let i = 0; i < x; i++) {
                if (grid[i][i1] === true) {
                    grid[i][i1] = false;
                    test = false;
                    player *= -1;
                    for (let i3 = 0; i3 < x; i3++) {
                        grid[i3][i1] = false;
                    }
                    for (let i4 = 0; i4 < y; i4++) {
                        grid[i][i4] = false;
                    }
                    break;
                }
            }
            if (!test) break;

        }

        if (test) break;
    }
    if (player * -1 == 1) {
        console.log("Akshat");
    } else {
        console.log("Malvika");

    }

}


const mainFunction = (lines) => {
    [a, b, c] = lines[0].split(" ").map(Number);
    if (b + c < a) {
        console.log(-1);
    } else {
        console.log(a);
    }
}

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


//'use strict';
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let currentLine = 0;
let i = '';
process.stdin.on('data', c => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  i = i.trim()
    .split(' ' || EOL)
    .map(string => {
      return string.trim();
    });
  main();
});

function readLine() {
  return i[currentLine++];
}
function main() {
  var x = readLine();
  var res = x / 5;
  if (x % 5 === 0) {
    console.log(res);
  }
  else console.log(res + 1);
}


// 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 frnLocation = str.trim();
    let moves = [1, 2, 3, 4, 5];
    let steps = stepsToTake(moves, +frnLocation);
    return steps.toString();
}

function stepsToTake(moves = [], frnLocation, steps = 0) {

    let newNum = 1;
    for (let row of moves) {
        if (row < frnLocation) {
            newNum = row;
        }
    }

    frnLocation = frnLocation - newNum;
    if (frnLocation !== 0) {
        steps++;
        return stepsToTake(moves, frnLocation, steps);
    }
    else {
        return steps;
    }
}


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 multiply(a, b) {
	a = a.toString(10).split('').reverse();
	b = b.toString(10).split('').reverse();

	if (a.length < b.length) {
		[a, b] = [b, a];
	}

	let res = Array(a.length + b.length).fill(0);
	for (let i = 0, lb = b.length; i < lb; ++i) {
		let carry = 0;
		let scarry = 0;
		for (let j = 0, la = a.length; j < la; ++j) {
			let m = b[i] * a[j];
			m += carry;

			if (m > 9) {
				let [c, d] = m.toString(10).split('');
				res[i + j] += (scarry >> 0) + (d >> 0);
				carry = c >> 0;
			} else {
				res[i + j] += (scarry >> 0) + m;
				carry = 0;
			}

			if (res[i + j] > 9) {
				let [c, d] = res[i + j].toString(10).split('');
				res[i + j] = d >> 0;
				scarry = c;
			} else {
				scarry = 0;
			}
		}
		if (carry > 0) res[a.length + i] = carry;
		if (scarry > 0) res[a.length + i] = scarry;
	}

	res.reverse();
	let mulVal = '';
	let flag = false;
	res.forEach(d => {
		if (!flag && d !== 0) flag = true;
		if (flag) mulVal += d;
	});
	return mulVal;
}

function main() {
	let n = readLine() >> 0;
	let f = readLine()
		.split(' ')
		.map(x => x >> 0);

	let s = f.reduce((a, c) => a + c);
	let t = n + 1;
	let r = s % t;
	r = r === 0 ? (r += 2) : r++;
	console.log(r);
}


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}

function main() {
    let n = parseInt(readLine());
    let fingersArray = readLine().split(' ').map(Number);
    let sum = 0;
    for (let i = 0; i < fingersArray.length; i++) {
        sum = sum + fingersArray[i];
    }
    let ways = 0;
    for (let i = 1; i <= 5; i++) {
        if ((sum + i) % (n + 1)) {
            ways++;
        }
    }
    console.log(ways);
}


//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);
	if(eleve < work){
		myout("YES");
	}else{
		myout("NO");
	}
}


const elevatorOrStairs = (argv) => {
  let x = argv[2],
    y = argv[3],
    z = argv[4],
    t1 = argv[5],
    t2 = argv[6],
    t3 = argv[7];

  let stairs = Math.abs((x - y) * t1);
  let elevator = Math.abs(x - z) * t2 + 3 * t3 + Math.abs(x - y) * t2;

  return elevator <= stairs ? 'YES':'NO';
}

let result = elevatorOrStairs(process.argv);

console.log(result);


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

function f(x) {
  ++x;
  while (x % 10 === 0) {
    x /= 10;
  }
  return x;
}

function sol() {
  const visited = {};
  let x = Number(input);
  let count = 1;
  while (!visited[f(x)]) {
    x = f(x);
    visited[x] = true;
    ++count;
  }
  process.stdout.write(count.toString(), 'utf8', () => process.stdout.end());
}


var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// When user input data and click enter key.
standard_input.on('data', function (s) {
s=s.trim().split()
    const n = s.reduce((a,c)=>
{
//console.log(a,c);
return a + 9-Number(c)
}
,(1 < s.length || s[0] === '0' ? 1 : 0) + Number(s[0]));
    console.log(n);
});


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

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;
	let [s, v1, v2, t1, t2] = inputReader.readNumberArray();

	let res1 = s * t1 + v1 * s;
	let res2 = s * t2 + v2 * s;
	if (res1 > res2) {
		console.log("First");
	} else if (res1 < res2) {
		console.log("Second");
	} else {
		console.log("Friendship");
	}

}

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 readNumberArray(){
		return _inputLines[_lineNumber++].split(' ').map(val => Number(val));
	}

	return {
		readNumberArray,
	}
}


function main() {
    // write code here:
    var arr = stdin[0].split(' ').map(Number);
    const n = arr.splice(0, 1)[0];
    var arrLen = arr.length;
    var v1 = arr[0], v2 = arr[1], t1 = arr[2], t2 = arr[3];
    var second1 = (arrLen - 2) * v1 + (v1 + t1) * 2;
    var second2 = (arrLen - 2) * v2 + (v2 + t2) * 2;
    if (second1 < second2) {
        console.log('First');
    } else if (second1 > second2) {
        console.log('Second');
    } else {
        console.log('Friendship');
    }
}

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


/**
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 > 1)
        digit.push(zeorCount);

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

}


/**
 * Created by bhavyaagg on 09/06/18.
 */

const readline = require('readline');

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

r1.on('line', (data) => {
  let x = data.split(" ")[0];
  let y = data.split(" ")[1];

  if (x == y) {
    console.log("=");
  } else if (x < y) {
    console.log(">")
  } else {
    console.log("<")
  }

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

// 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, count1] = [0, 0];
  const str = readLine();

  for (let i = 0; i < str.length; i++) {
    if (str[i] === "0") count0++;
    else count1++;
  }

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


const solve = () => {
  const vk = (s.match(/VK/g) || []).length
  const vv = (s.match(/VV/g) || []).length > 0
  const kk = (s.match(/KK/g) || []).length > 0

  print(vk + (vv || kk ? 1 : 0))
}

solve()
// I/O Functions
const __lines = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .split('\n')
let __lineIndex = 0
const line = () => __lines[__lineIndex++]
const words = () => line().split(' ')
const int = () => parseInt(line())
const ints = () => words().map(x => parseInt(x))
const float = () => parseFloat(line())
const floats = () => words().map(x => parseFloat(x))

const print = console.log


async function solve() {
  let s = await line()
  const vk = (s.match(/VK/g) || []).length
  s = s.split('VK').join('')
  const vv = (s.match(/VV/g) || []).length > 0
  const kk = (s.match(/KK/g) || []).length > 0

  print(vk + (vv || kk ? 1 : 0))
}

// read the input
const readline = require('readline')
const _lines = []
let _lineIndex = 0
let _ended = false
const _rl = readline.createInterface(process.stdin)
_rl.on('line', line => _lines.push(line))
_rl.on('end', () => (ended = true))
const wait = ms => new Promise(resolve => setTimeout(resolve, ms))
const line = async () => {
  while (!_ended && _lines.length <= _lineIndex) await wait(10)
  const result = _lines[_lineIndex].trim()
  _lines[_lineIndex] = null
  _lineIndex++
  return result
}
const words = async () => (await line()).split(' ')
const chars = async () => (await line()).split('')
const int = async () => parseInt(await line())
const ints = async () => (await words()).map(x => parseInt(x))
const big = async () => BigInt(await line())
const bigs = async () => (await words()).map(x => BigInt(x))

const print = console.log

solve()


const readline = require("readline");

let inputs = [];

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

rl.on("line", line => inputs.push(line));

rl.on("close", () => console.log(solution(inputs)));

function solution([_, data]) {
	const columns = data.split(" ").map(Number);
	const ans = columns.sort((a, b) => a - b);
	return ans;
};


"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 x = readline().split(" ");

  const x2 = readline()
    .split(" ")
    .map((x) => +x);

  fn(x2);
}

function fn(arr) {
    console.log(arr.sort().join(" "))
}


'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 print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  // input
  let n = readline();
  const numbers = readline().split(' ').map(x => parseInt(x)).sort();

  // output
  print(numbers.join(' '));
}


'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 x=parseInt(readLine())
	let blocks=readLine().split(" ").map(n=>+n)
	blocks.sort()
	console.log(...blocks)
}


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

let currentLine = 0;
let inputString = "";

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

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

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

/******** Main function*************/

function main() {
  var n = +readLine();
  var m = readLine().split(" ").map(Number);

  console.log(m.sort().join(" "));
}


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

function transform(data, j) {
    for (let i = j; i < length - 1; i++) {
        if (data[i] === 'B' && data[i + 1] === 'G') {
            const temp = data[i];
            data[i] = data[i + 1];
            data[i + 1] = temp;
            i++;
        }
    }
    return data;
}

function solve(data) {
    for (let i = 0; i < t; i++) {
        data = transform(data, i);
    }
    return data;

}

rl.on('line', (line) => {
    if (!length) {
        [length, t] = line.split(' ').map(Number);
        return
    }
    console.log(solve(line.split('')).join(''));
});


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() {
  let [len, time] = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  let arr = readLine().split("");

  for (let i = 0, j = 0; i < len - 1; i++) {
    if (arr[i] === "B" && arr[i + 1] === "G") {
      j++;
      if (j <= time) {
        [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];
      } else j = 0;
    } else j = 0;
  }
  console.log(arr.join(""));
}


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

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

readLine.on('close', () => {
  let [first, second] = input
  let [people, seconds] = first.split(' ')
  let arrOrder = second.split('')
  for (let a = 0; a < seconds; a++) {
    for (let b = 0; b < people; b++) {
      const el = arrOrder[b]
      if (el === 'G') {
        arrOrder[b] = el
      } else if (el === 'B') {
        const checkNext = arrOrder[b + 1]
        if (checkNext === 'G') {
          arrOrder[b] = 'G'
          arrOrder[b + 1] = 'BG'
        } else {
          arrOrder[b] = el
        }
      } else {
        arrOrder[b] = 'B'
      }
    }
  }
  console.log(arrOrder.toString())
});


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}

function main() {
    let nums = readLine().split(' ').map(Number);
    let [studentNums, seconds] = nums;
    let studentOrder = readLine();
    for (let i = 0; i < seconds; i++) {
        // [BGGBG]
        for (let j = 0; j < studentOrder.length; j++) {
            if (studentOrder[j] === 'B' && studentOrder[j + 1] === 'G') {
                studentOrder[j] = 'G';
                studentOrder[j + 1] = 'B';
                j++;
            }
        }
    }
    console.log(studentOrder);
}


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


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

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;
	let [n, k] = inputReader.readNumberArray();
	let arr = inputReader.readNumberArray();
	let total = 0,
		extra = 0,
		flag = false,
		days = 0;
	for (let i = 0; i < arr.length; i++) {
		if (arr[i] >= 8) {
			total += 8;
			extra += arr[i] - 8;
			days++;
		} else {
			total += arr[i];
			if (extra > 0) {
				let temp = 8 - arr[i];
				extra -= temp;
				total += temp;
			}
			days++;
		}
		if (total >= k) {
			flag = true;
			break;
		}
		//console.log(total, extra);
	}
	if (flag) console.log(days);
	else console.log(-1);

}

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 readNumberArray(){
		return _inputLines[_lineNumber++].split(' ').map(val => Number(val));
	}

	return {
		readNumberArray,
	}
}