'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 ans(s)
{
    let zer=[-1,-1],tw=-1,se=-1,fi=-1;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='7')
        {
            se=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='2')
        {
            tw=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='5')
        {
            fi=i;
            break;
        }
    }
    let k=0;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='0')
        {
            zer[k++]=i;
            if(k==2)
                break;
        }
    }
    zer.length=k;
    if(fi==-1)
    {
        if(zer.length<2)
            return -1;
        return (2*s.length-3-zer[0]-zer[1]);
    }
    else
    {
        let ac=[];
        if(zer.length>=2)
        {
            ac.push(2*s.length-3-zer[0]-zer[1]);
        }
        if((zer.length>=1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-zer[0]-fi+(fi>zer[0]?1:0));
        }
        if((tw!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-tw-fi+(tw>fi?1:0));
        }
        if((se!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-se-fi+(se>fi?1:0));
        }
        if(ac.length!=0)
            return Math.min.apply(Math,ac);
        else
            return -1;
    }
}
function main()
{
    let n=readLine().trim();
    console.log(ans(n));
}


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

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

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

  let sum = 0;
  let ans = 0;

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

  console.log(ans);

  c++;
});


function businessTrip(k, months) {
  // sort the array
  months = months.split(" ");
  months = months.sort(function(a, b) {
    return b - a;
  });
  // itarate
  let count = 0;
  let sum = 0;
  for (let i = 0; i < months.length; i++) {
    if (k == 0) break;
    if (k <= parseInt(months[i]) + parseInt(sum)) {
      count++;
      break;
    } else {
      sum = parseInt(sum) + parseInt(months[i]);
      count++;
    }
  }
  return console.log(count);
}

// businessTrip("0", "0 0 0 0 0 0 0 1 1 2 3 0");

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

let arr = [];
rl.on("line", line => {
  arr.push(line);
});

rl.on("close", () => {
  businessTrip(arr[0], arr[1]);
});


function businessTrip(k, months) {
  // sort the array
  months = months.split(" ");
  months = months.sort(function(a, b) {
    return b - a;
  });
  // itarate
  for (let i = 0; i < months.length; i++) {
    let sumOfFirsNLement = months
      .slice(0, i + 1)
      .reduce((startPoint, current) => {
        return parseInt(startPoint) + parseInt(current);
      });
    if (parseInt(sumOfFirsNLement) >= parseInt(k)) return console.log(i + 1);
  }
  return console.log("-1");
}

// let sum = [1, 2, 3];

// console.log(sum);

// businessTrip("5", "0 0 0 0 0 0 0 1 1 2 3 0");

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

let arr = [];
rl.on("line", line => {
  arr.push(line);
});

rl.on("close", () => {
  businessTrip(arr[0], arr[1]);
});


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

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

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

	m.sort((a, b) => b - a);

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

	let c = 0,
		s = 0;
	for (let i = 0; i < 12; ++i) {
		s += m[i];
		if (s >= n) {
			c++;
			break;
		}
		c++;
	}
	console.log(c);
}


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 k = parseInt(readLine());
    let months = readLine().split(' ').map(Number);
    months.sort((a, b) => b - a);
    if (k === 0) {
        console.log(0);
        return;
    }
    let count = 0;
    let sum = 0;
    for (let i = 0; i < months.length; i++) {
        sum = sum + months[i];
        count++;
        if (sum >= k) {
            break;
        }
    }
    console.log(count);
}


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

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

  const arr = d.split(' ').map(Number);
  const sum = arr.reduce((a, b) => a + b, 0);
  let max = Math.max(...arr);
  let r = 0;

  for (let i = 0; i < arr.length; i++) {
    r += max - arr[i];
  }

  // while (r <= sum) {
  //   r += arr.length;
  //   max++;
  // }

  if (sum - r >= 0) {
    max += Math.ceil((sum - r) / arr.length);
  }

  console.log(max);

  c++;
});


input = []
process.stdin.setEncoding('ascii');
process.stdin.on('data', z => {
    input.push(z.slice(0, -1))
})

process.stdin.on('end', z => {
    // console.log(input)
    a = input[1].split(' ')
    b = input[2].split(' ')
    // console.log(a, b)
    for(let i in a){
        if(b.includes(a[i])){
            process.stdout.write(a[i] + ' ')
        }
    }
    process.stdout.write('\n')
})


let numbers = readline().split(' ').map((n) => parseInt(n));
let [n, m, a] = numbers;

let an = Math.ceil(n / a);
let am = Math.ceil(m / a);

print(an * am);


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

let standardInputString= '';
let currentLine = 0;

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

process.stdin.on('data', rawData =>{
  standardInputString += rawData;
});

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

  main();
})

function main(){
    let [n] = readLine().split(' ').map(Number);

   let line = readLine().split(' ').map(Number);

    let consecutives = 0;

  let result = 0;

    for(let i =1; i<=n; i++){
      if(line[i]-1 ===line[i-1]&& line[i+1] -1 === line[i]){
        consecutives++;
      }
      else{
        consecutives = 0;
      }
      result = Math.max(result, consecutives);
    }
    console.log(result)
  }


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

let l = 0;
rl.on('line', (input) => {
    if (l === 0) { l++ }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        let cnt = 0
        let max = 0
        for (let i = 1; i < arr.length; i++) {
            if (arr[i]===arr[i-1]+1) {
                cnt++
                if(i+1<arr.length&&arr[i]+1!==arr[i+1]){
                    cnt--
                }
                if(cnt>max){
                    max=cnt
                }
            } else {
                cnt=0
            }
        }
        console.log(max)
        return 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 solve(n) {
	if (n < 2) return 0;
	return 2 + solve(n - 2);
}

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

	if ((n & 1) === 1) {
		console.log(0);
	} else {
		console.log(r);
	}
}


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

rl.on('line', (d) => {
  const [n, m, k] = d.split(' ').map(Number);
  let inc = 1;
  const matrix = new Array(n).fill(0).map(x => new Array(m).fill(0)).map(row => row.map(col => {
    const pair = [inc, inc+1];
    inc += 2;
    return pair;
  }));

  let x, y;
  isDone :{
    for (let i = 0; i < matrix.length; i++) {
      for (let j = 0; j < matrix[i].length; j++) {
        for (let z = 0; z < matrix[i][j].length; z++) {
          if (matrix[i][j][z] === k) {
            x = i + 1;
            y = j + 1;
            break isDone;
          }
        }
      }
    }
  }

  console.log(x, y, k % 2 ? 'L' : 'R');

  c++;
});


let data = '';
process.stdin.on('data',c => data += c);
const solution = () => {
	let [n, k, m] = data.split(' ').map(v => parseInt(v, 10));
	let r = Math.trunc(m / (2 * k)) + (((m%(2*k)) > 0)?1:0);
	let d = Math.trunc((m%(2 * k))/ 2) + (((m%(2 * k))%2 > 0)?1:0);
	let v = (m%2 === 0)?"R":"L";
	console.log(`${r} ${d} ${v}`);
};

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


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

rl.on('line', (d) => {
  let n = +d;
  const arr = ['D', 'A', 'C', 'B'];

  if (n % 4 === 3 || n % 4 === 1) {
    console.log(0, arr[n % 4]);
  }
  else {
    console.log(1, arr[(n + 1) % 4]);
  }
});


//1191A

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

function rankHP(currentHP){
    if(currentHP % 4 == 1){
        return(1);
    } else if(currentHP % 4 == 3) {
        return(3);
    } else if (currentHP % 4 == 2) {
        return(2);
    } else if (currentHP % 4 == 0) {
        return(0);
    }
}

function rankAchievedToLetter(rankAchieved){
    if(rankAchieved == 1){
        return(' A');
    } else if(rankAchieved == 3) {
        return(' B');
    } else if (rankAchieved == 2) {
        return(' C');
    } else if (rankAchieved == 0) {
        return(' D');
    }
}

function getResult(hp){
    let ranks = [0,0,0];
    let rankAchieved = rankHP(hp);
    if (rankAchieved == '1'){
        return 0 + rankAchievedToLetter(rankAchieved);
    } else {
        ranks = [rankAchieved, rankHP(hp+1), rankHP(hp+2)];
        //console.log(ranks);
        if (ranks.includes(1)){
            obama = rankHP(ranks[ranks.indexOf(1)]);
            //console.log(obama);
            return (hp+ranks.indexOf(1)) + rankAchievedToLetter(obama);
        } else {
            obama = ranks[ranks.indexOf(Math.max(...ranks))];
            //console.log(obama);
            return (hp+ranks.indexOf(Math.max(...ranks))) + rankAchievedToLetter(obama);
        };

    };
};

rl.question('', (answer) => {
    hp = answer;
    //console.log('hp', hp, typeof hp);
    console.log(getResult(parseInt(hp)));
    process.exit();
});


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

intInput.on('line', (line) => {
	arr = line.split(" ")
});
intInput.on('close', () => {
	let result = 'NO';
	let [memb, pen, note] = arr;
	if ( pen >= memb && note >= memb ) {
		result = 'YES'
	}
	console.log(result);
})


const black = 'B';
const white = 'W';

function is_row_all_black(row) {
  for (const sqr of row) {
    if (sqr === black) {
      // do nothing ...
    } else {
      return false;
    }
  }
  return true;
}

function is_column_all_black(rows, i) {
  for (const row of rows) {
    const sqr = row[i];
    if (sqr === black) {
      // do nothing ...
    } else {
      return false;
    }
  }
  return true;
}

function solve(rows) {
  let result = 0;
  for (const row of rows) {
    result = result + (is_row_all_black(row) ? 1 : 0);
  }
  for (let i = 0; i < rows.length; i = i + 1) {
    result = result + (is_column_all_black(rows, i) ? 1 : 0);
  }
  return result;
};

function main(lines) {
  const rows = [];
  for (const line of lines) {
    const t = line.trim();
    if (t.length > 0) {
      rows.push(t);
    }
  }
  const result = solve(rows);
  console.log(result);
};

async function processLinesFromStream(rs, pf) {
  const content = [];
  rs.setEncoding("utf-8");
  for await (let chunk of rs) {
    content.push(chunk);
  }
  const lines = content.join('').split(/\n/);
  const result = pf(lines);
  return result;
};

processLinesFromStream(process.stdin, main);


const readline = require('readline');

const cl = readline.createInterface( process.stdin, process.stdout );
function question(q='') {
    return new Promise( (res, rej) => {
        cl.question( q, answer => {
            res(answer);
        })
    });
};

(async function main() {
    const numberLines = 8;
    const input = [];
    for (let i = 0; i < numberLines; i++) {
        // console.log('Asking');
        input.push(await question(''));
        // console.log(input, i)
    }
    const result = solve(input);
    process.stdout.write(result.toString());
})();

function solve(input) {
    // console.log('asdasa',input);
    const arr = input.map(row => row.trim().split(''));
    let counter = 0;
    const row = arr.find(r => r.some(i => i === 'W'));
    // console.log(row);
    if (row) row.forEach(i => i === 'B' && counter++);
    // console.log(counter);
    counter += arr.filter(row => row.every(i => i === 'B')).length;
    // console.log(arr);
    // console.log(arr.filter(row => row.every(i => i === 'B')))
    return counter;
}


const readline = require("readline");

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

var n = 8;
var answer = 0;
var counter = 0;
var check = true;

rl.on("line", input => {
  if (n > 0) {
      counter = 0;
    for (var i = 0; i < input.length; i++) {

      if (input[i] == "B") {
        counter++;
      }
    }

    if (counter == 8) {
      answer++;
    }
    else if (check && counter > 0) {
      answer += counter;
      check = false;
    }
    n--;
  }
  else
  {
    console.log(answer);
    rl.close();
  }

});


const readline = require("readline");

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

var answer = 0;
var counter = 0;
var check = true;

rl.on("line", input => {

      counter = (input.match(/B/g)).length;

    if (counter == 8) {
      answer++;
    }
    else if (check && counter > 0) {
      answer += counter;
      check = false;
    }

}).on("close", () => {
    console.log(answer);
  });


const readline = require('readline');

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

var ans = 0,
    metColumn = false;

rl.on('line', (s) => {

    if (s == 'BBBBBBBB')
        ans++;
     else if (!metColumn) {
         //console.log("inside else if metColumn= &s",metColumn)
        ans += s.search(/B/);
        metColumn = true;
    }

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

});


const readline = require('readline');

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

var ans = 0,
    metColumn = false;

rl.on('line', (s) => {

    if (s == 'BBBBBBBB')
        ans++;
     else if (!metColumn) {
         //console.log("inside else if metColumn= &s",metColumn)
        ans += s.match(/B/g).length;
        metColumn = true;
    }

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

});


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

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

  const arr = d.split(' ').map(Number);
  let amount = 0;

  for (let i = 0; i < n - 1; i++) {
    amount += arr[i];
  }

  if (amount > s) {
    console.log('NO');
  }
  else {
    console.log('YES');
  }

  c++;
});


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

rl.on('line', (data) => {
  let [a, b, c, d] = data.split(' ').map(Number);
  let p1Points = Math.max(a/10, a - (a / 250) * c);
  let p2Points = Math.max(b/10, b - (b / 250) * d);

  if (p1Points === p2Points) {
    console.log('Tie');
  }
  else if (p1Points > p2Points) {
    console.log('Misha');
  }
  else {
    console.log('Vasya');
  }

  count++;
});


'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, ar) {
    ar.sort((a, b) => a - b);
    let ans = (ar[n - 1] - ar[0]) % 2 === 0 ? (ar[n - 1] - ar[0]) / 2 : -1;
    for (let i = 0; i < n; i++) {
        if (ar[i] !== ar[0] && ar[i] !== ar[n - 1] && ar[i] !== ar[0] + ans) ans = -1;
    }
    return ans;
}

function main() {

    const nk = readLine();

    const n = readInt(nk[0]);
    const a = readIntArray(readLine());

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


var readline = require('readline-sync');
a = [];
x = readline.question('');
a1 = x.split(' ');
for (var i = 0; i < a1.length; i++) {
    a.push(Number(a1[i]));
}
a.sort((a,b) => {
    return a-b;
});

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


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

rl.on('line', (d) => {
  const arr = d.split(' ').map(Number).sort((a, b) => a - b);
  const ans = arr[0] + arr[3] === arr[1] + arr[2];

  if (ans) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }
});


/*
* У Давида есть четыре мешка с конфетами. В i-м из них лежит ai
* конфет. Также у Давида есть два друга. Он хочет отдать каждый мешок одному из двух друзей.
* Возможно ли так распределить мешки, чтобы два друга получили одинаковое общее число конфет?
* Обратите внимание, что вы не можете оставить мешки себе или выбросить их,
* каждый мешок должен быть отдан одному из двух друзей.
* Входные данные:
* В первой строке записаны четыре целых числа a1, a2, a3 и a4 (1 ≤ ai ≤ 100) — количества конфет в каждом мешке.
* Пример входных данных: 1 7 11 5
* Выходные данные:
* Выведите YES || NO
*/

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

rl.on('line', function(line){
    var candies = line.split(" ");
    var sum = 0;
    candies.forEach(function (elem) {
        sum = sum + parseInt(elem);
    });
    console.log((sum % 2) ? 'NO': 'YES');
});


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

rl.on('line', (d) => {
  const n = +d;
  console.log(1);
});


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

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

  if (c === 1) {
    arr1 = d.split(' ').map(Number);
    c++;
    return;
  }

  arr2 = d.split(' ').map(Number);

  c++;
});

rl.on('close', () => {
  let common = 0;

  for (let i = 0; i < arr1.length; i++) {
    common += arr1[i] && arr2[i];
  }

  let sum1 = arr1.reduce((a, x) => a + x, 0) - common;
  let sum2 = arr2.reduce((a, x) => a + x, 0) - common;
  let ans = sum1 > sum2 ? 1 : -1;

  for (let i = 2; i <= max; i++) {
    if (sum1 * i > sum2) {
      ans = i;
      break;
    }
  }

  console.log(ans);
});


const processData = (lines) => {
  const k = lines[1].split(' ').map(x => +x)
  const l = lines[2].split(' ').map(x => +x)
  let diff = [0, 0]
  for (let i =0; i<k.length; i++) {
    if (k[i] !== l[i]) {
      if (k[i] === 1) {
        diff[0]++
      }
      if (l[i] === 1) {
        diff[1]++
      }
    }
  }
  if (diff[0] === 0) {
    console.log(-1)
  } else {
    let rest = Math.ceil(diff[1]/diff[0])
    if (diff[1]%diff[2] === 0) {
      rest++
    }
    console.log(rest)
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})


function main(rawInput) {
    var lines = rawInput.trim().split("\n").map(function (v) { return v.trim().split(" ").map(function (u) { return parseInt(u, 10); }); });
    var n = lines.shift()[0];
    var ra = lines.shift();
    var rb = lines.shift();
    var sca = 0;
    var scb = 0;
    var unqa = 0;
    for (var i = 0; i < n; i++) {
        if (ra[i] == 1) {
            sca++;
        }
        if (rb[i] == 1) {
            scb++;
        }
        if (ra[i] > rb[i]) {
            unqa++;
        }
    }
    // console.error(sca, scb, unqa);
    if (sca > scb) {
        console.log(1);
    }
    else if (unqa > 0) {
        var ned = Math.ceil((scb - (sca - unqa)) / unqa) + 1;
        console.log(ned);
    }
    else {
        console.log(-1);
    }
    // console.log('----')
}
// main(`5
// 1 1 1 0 0
// 0 1 1 1 1`);
// main(`3
// 0 0 0
// 0 0 0`);
// main(`4
// 1 1 1 1
// 1 1 1 1`);
// main(
//     `9
// 1 0 0 0 0 0 0 0 1
// 0 1 1 0 1 1 1 1 0`
// );
// main(`2
// 1 1
// 1 0`);
// main(`3
// 0 1 1
// 1 0 0`);
// main(`7
// 0 1 1 1 0 1 1
// 1 0 1 1 1 1 1`);
(function () {
    var d = "";
    process.stdin.on("data", function (v) { return d += v; });
    process.stdin.on("end", function () { return main(d); });
})();


let input = [];

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

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

RL.on('close', () => {
    let {0:a, 1:b, 2:c} = {...input[0].split(' ')};
    a = parseInt(a); b = parseInt(b); c = parseInt(c);

    if(Math.abs(a - b) <= 1) {
        console.log(a + b + (c*2));
    } else {
        console.log(a + b + (c*2) - Math.abs(a-b-1));
    }
});


'use strict';
// 9- 8- 8- 7- 7- 7- 7- 7- 7-  6- 5- 3- 2- 2- 2 2- 2- 2 1- 1- 1 0- 0-

// 7 4 2  - - - - -
// value = 3
// arr[minIndx] = 4
// min = 1
// 4  - - -

// 9 8 8 7 6 5 4 2 1 0
// 7 7 7 2 1 0
// 7 7 2 2 1
// 1 1
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let arr = []
let input = []
let n;
var readline = require('readline')

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

process.stdin.on('end', _ => {
    input = input.trim().split('\n').map(string => {
        return string.trim();
    });
    n = input[0]
    arr = input[1].split(" ")
    arr = arr.map(s=>parseInt(s))
    main();
});
function main() {
    // console.log("len",arr.length)
  let visted = {};
  arr.sort();
  arr.reverse();
  function findMinDifference(value) {
    let min = 100000000;
    let minIndex;
    for (let i = 0; i < arr.length; i++) {
      if (visted[i]) continue;
      if (Math.abs(arr[i] - value) < min  ) {
        min = Math.abs(arr[i] - value);
        minIndex = i;
      }
    }
    visted[minIndex] = true;
    return arr[minIndex];
  }
  let pils = 1;
//   console.log("arr",arr)
  let boxesCanHold = arr[0]; // 9
  visted[0] = true;
    //  console.log("will start with",arr[0])

  for (let i = 0; i < arr.length; i++) {
    if (visted[i]) continue;
    if(boxesCanHold ==0){
        boxesCanHold = arr[i];
        visted[i] = true;
        ++pils;
        // console.log("will start with",arr[i])
    }
    if(boxesCanHold!=0){
     let nextStrength = findMinDifference(boxesCanHold-1);
     boxesCanHold = nextStrength >= boxesCanHold ? --boxesCanHold : nextStrength;
    //  console.log(nextStrength," ",boxesCanHold)
    }
    boxesCanHold = boxesCanHold < 0 ? 0 : boxesCanHold;
    if (boxesCanHold == 0 && Object.keys(visted).length != arr.length) {
        // console.log("here")
        i = 0;
    }
    if(i == arr.length-1 && Object.keys(visted).length != arr.length){

    }
            i = 0;

  }
  console.log(pils );

}


const readline = require('readline');

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

rl.question('', (answer) => {
    // TODO: Log the answer in a database

    check(answer);

    rl.close();
});

function check(x) {
  var arr = x.split(" ");
  let  F = arr[0];
  let  S = arr[1];
  let counter = 0;

    while (F <= S) {

        for (let k in arr) {
            if (k == 0) {
                F = F * 3;
            }

            if (k == 1) {
                S = S * 2;
            }

        }
        counter++;
    }

console.log(counter);

}


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

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

readLine.on('close', () => {
// CODE HERE
	let [a, b] = input[0].split(' ').map(x => +x);
	for(let i = 1; i > 0; i++){
          a = 3*a;
          b = 2*b;
          if ( a > b){
            return i;
          }
    }
});


let lines = [];
require('readline').createInterface({input: process.stdin,output: process.stdout})
				.on('line', line => {lines.push(line);})
				.on('close', () => {console.log(main(lines));});

const main = (input) => {
	let [a, b] = input[0].split(" ");
	let counter = 0;
	while (a <= b) {
		counter++;
		a *= 3;
		b *= 2;
	}
	return counter;
}


const readline = require('readline');

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

let limak = 0;
let bob = 0;
let years = 0;
rl.on("line",(input)=>{
    limak = input.split(" ")[0]
    bob = input.split(" ")[1]
    while(limak<=bob){
        bob*=2
        limak*=3
        years++
    }
    console.log(years)
    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();
    });

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

     bearAndBigBrother(x[0],x[1]);
 }

function bearAndBigBrother(a, b) {
  let counter = 0;

  while (a <= b) {
    a *= 3;
    b *= 2;
    counter++;
  }

  console.log(counter)

  return counter;
}


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 a,b;
function main() {
  [a,b] = lines[0].map(x => parseInt(x))
  predict(["1<=a<=b<=10"])
  let years = 0
  for (;;years++) {
    if (a <= b ){
        a += a*3
        b += b*2
        continue;
    }
    else break;
  }
  print(years)
}


const readline = require('readline')

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

async function getData() {
	return new Promise((res,rej)=>{
		rl.question('',answer=>res(answer))
	})

}
function counted(limak,bob){
	let years = 0

	while(limak <= bob){

		years++
		limak *= 3
		bob *= 2

	}
	console.info(years)
}

async function main(){

	let data = await getData()
	rl.close()
	data = data.trim().split(' ')

	counted(...data)
}

main()


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

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

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


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

rl.on('line', (d) => {
    let [a, b] = d.split(' ').map(Number);
    let ans = 0;

    while (a < b) {
        a *= 3;
        b *= 2;
        ans++;
    }

    console.log(ans);
});


const readline = require('readline')

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

rl.on('line', line => {
  const [a, b] = line.split(' ')
  console.log(solve(a, b))
})

function solve(a, b) {
  let years = 0

  while (a <= b) {
    a *= 3
    b *= 2
    years++
  }

  return years
}


const readline = require('readline');

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

rl.on('line', function(line){
    const sp = line.split(' ');
    let lcw = sp[0];
    let bcw = sp[1];
    let y = 0;

    while (bcw > lcw) {
        y++;
        lcw *= 3;
        bcw *= 2;
    }

    console.log(y);
});


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

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

readline.on('close', () => {
    const [m, l] = Array.from(input[0].split(' '), x => parseInt(x));
    let x = Math.round((m + l) / 5);
    x = x > 0 ? x : 1;
    console.log(x);
});


var input='';

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

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

const main=(input)=>{
    let limak=input.split(' ')[0];
    let bob=input.split(' ')[1];
    let count=0;

    while(true){
        if(limak>bob){
            break;
        }
        limak*=3;
        bob*=2;
        count++;
    }

    console.log(count);
};


'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(), 10);
    let ans = 0;
    let passInside = 0;
    for (let i = 0; i < n; i++) {
        let arr = readLine()
            .split(' ')
            .map(value => parseInt(value));

        passInside = passInside - arr[0] + arr[1];
        if (passInside > ans) {
            ans = passInside;
        }
    }
    console.log(ans);
}


'use strict';

const readline = require('readline');

let lines = [];

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

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

rl.on('close', (cmd) => {
    let arr = lines[0].split(' ').map(Number);
    let ret = 0;
    while (3 * arr[0]++ < 2 * arr[1]++) { ++ret; }
    console.log(ret);
    process.exit(0);

});


const readline = require('readline');

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

rl.question('', (answer) => {
    const argumentArray = answer.split(' ');
    let bearWeight = argumentArray[0];
    let brotherWeight = argumentArray[1];
    let year = 0;

    while(brotherWeight >= bearWeight) {
        bearWeight *= 3;
        brotherWeight *= 2;
        year++;
    }

    console.log(year);

    rl.close();
});


function pangram(stringLength, word) {

    let alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
    let stringToMap = {};
    let occurance = {};
    word = word.toLowerCase();

    for (let index = 0; index < stringLength; index++) {
        stringToMap[word[index]] = 1;
    }

    for (let index = 0; index < alphabet.length; index++) {
        if (stringToMap[alphabet[index]])
            occurance[alphabet[index]] = 1
    }

    if(Object.keys(occurance).length == alphabet.length)
      return 'YES';

    return 'NO';
}


function solve(n, str) {
    str = str.toLowerCase();
    let m = {};
    for (let c = 'a'.charCodeAt(0); c <= 'z'.charCodeAt(0); c++) {
        m[c] = false;
    }
    str.split('').forEach(letter => {
        m[letter.charCodeAt(0)] = true;
    });
    for (var key in m) {
        if (m.hasOwnProperty(key) && m[key] === false) {
            return "NO\n";
        }
    }
    return "OK\n";
}

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


function main(input) {

        let a,c,d =[];
        let l,i=1,v=1;
        input =input.split(/\n/g);
        a = input[0].split('');
        //console.log(a);
        l = a.length;

          c=first(Number(a[2]),Number(a[4]));
          d=second(Number(a[6]),Number(a[8]),Number(a[0]));
          l=c.length

          while(i<l){

              if(c[i]==d[i]){
                  console.log("YES");
                  v=0;
                  break;
              }
              i++;

          }
          if(v==1){
              console.log("NO");
          }

}

function first (a,b){
               var x=[],t=0;
               while(t<b){
                   x[t]=a++;
                   t++
               }
               return x;
}

function second (b,c,d){
            var y=[],t=0;
            y[0]=b;
            while(b!=c){
                if(b>1){
                    t++;
                    y[t]=--b;
                }
                else{
                    b=d;
                }
            }
            return y;
}

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

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

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


function main(input) {

        let a,b,c,d =[];
        let l,i=1,v=1;
        input =input.split(/\n/g);
        a = input[0].split(' ');
        l = a.length;

          c=first(Number(a[1]),Number(a[2]),Number(a[0]));
          d=second(Number(a[3]),Number(a[4]),Number(a[0]));
          l=c.length

          while(i<l){

              if(c[i]==d[i]){
                  console.log("YES");
                  v=0;
                  break;
              }
              i++;

          }
          if(v==1){
              console.log("NO");
          }

}

function first (a,b,d){
               var x=[],t=0;
               while(t<d){
                   if(a!=d){
                   x[t]=a++;
                   t++;}
                   else{
                       a=d;
                       x[t]=d;
                       t++;
                   }
               }
               return x;
}

function second (b,c,d){
            var y=[],t=0;
            y.push(b);
            while(b!=c){
                if(b>1){
                    t++;
                    y[t]=--b;
                }
                else if(b!=d){
                    b=d;
                    y[++t]=b;
                }
                else{

                }
            }
            return y;
}

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

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

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


function main(input) {

        // console.log(input,"ii");
        input =input.split(/\n/g);
        a = input[0].split(' ');
        // l = a.length;
        let n = a[0];
        let a = a[1];
        let x= a[2];
        let b = a[3];
        let y = a[4];
        var print = "NO";
          let min = Math.min(parseInt(x-a),parseInt(y-b),parseInt(n));
        for(let i =0;i<= min;i++){
            if(a==b){
                // console.log();
                print = "YES";
                break;
            } else {
                a++;
                b--;
            }
        }
        console.log(print);

}

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

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

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


function main(input) {

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

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

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

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

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

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

}

// main('33 15 6 1 3');

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

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

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


const DanielNext = (curr, n) => {
    return
}
const VladNext = (curr, n) => {
    return (curr === 1) ? n : (n - 1);
}

let z = '';
process.stdin.on('data', c => z += c);
process.stdin.on('end', () => {
    const {
        EOL
    } = require('os');
    let input = z.split(EOL)[0];
    input = input.split(' ').map(item => parseInt(item));
    while (true) {
        console.log(input[1],input[3])
        if (input[1] === input[3]) {
            console.log('YES');
            return 0;
        }
        if (input[1] === input[2] || input[3] === input[4]) {
            break;
        }

        input[3] = (input[3] === 1) ? input[0] : (input[3] - 1);
        input[1] = (input[1] === input[0]) ? 1 : (input[1] + 1);
    }
    if (input[1] === input[3])
        console.log('YES');
    else
        console.log('NO');

});


const readline = require('readline');

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

rl.on('line', (name) => {
    let newName = ""
    for(let i = 0; i < name.length; i++){
        if(newName.indexOf(name[i]) == -1){
            newName = newName + name[i]
        }
    }
    let message = newName.length % 2 == 0 ? "CHAT WITH HER" : "IGNORE HIM!"
    console.log(message)
    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 nums = input[1].split(' ').map(x => parseInt(x));

    let myString = input[0];

 let bySet= new Set ()

for (let i = 0; i < myString.length; i++) {
     bySet.add (myString[i])

}

    if (bySet.size()%2==0) {
        console.log('CHAT WITH HER!');

    }else {
        console.log('IGNORE HIM!')
    }

});


var run = input => (input.split('').filter(function(item, i, ar){ return ar.indexOf(item) === i; }).join('').length % 2 == 0) ? 'CHAT WITH HER' : 'IGNORE HIM!';

process.stdin.setEncoding('utf8');

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

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

    process.exit(0);

});


const readline = require("readline");

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

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


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

readline.question('enter the string you want', str=>{
    let arr=[];
    for(let i=0;i<str.length;i++){
        if(!arr.includes(str[i])){
            arr.push(str[i])
        }
    }
    if(arr.length%2===0){
        console.log('CHAT WITH HER!')
    }
    else{
        console.log('IGNORE HIM!')
    }
})


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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

const main=()=>{
	let counts={}
	let userName=readLine()
	for(let char of userName)
		if(counts[char]==undefined)
			counts[char]=1
		else counts[char]++

	let uc=0
	for(let key in counts){
		if(counts[key]==1)
			uc++
	}

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


'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 s = readLine().split('');
    s = [...new Set(s)];
    let count = 0;
    for (let i = 0; i < s.length; i++) {
        if (s[i].charCodeAt(0) % 2 != 0) {
            count++;
        }
    }
    if (count % 2 == 0) {
        console.log('CHAT WITH HER!');
    } else console.log('IGNORE HIM!');
}


// var num = readline().split(" ").map(x => parseInt(x));
const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
let input = [];
readline.on('line', line => {
  input.push(line);
});
process.stdin.on('end', () => {
  const inp = input[0].split(' ');
  const max = Math.max(inp[0], inp[1]);
  let result;
  if (max === 1) {
    result = 1/1
  } else if (max === 6) {
    result = 0/1;
  } else {
    result = (max-1)/6
  }
  console.log(result);
  return result;
});


// var num = readline().split(" ").map(x => parseInt(x));
const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
let input = [];
readline.on('line', line => {
  input.push(line);
});
  console.log({input})
  const max = Math.max(input[0][0], input[0][1]);
  let result;
  if (max === 1) {
    result = 1/1
  } else if (max === 6) {
    result = 0/1;
  } else {
    result = 6/(max-1)
  }
  console.log(result);
  return result;


const readline = require('readline');

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

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

rl.on('line', (input) => {
    var cont = input.split(' ').map(item => parseInt(item));
    var w = cont[0];
    var y = cont[1];
    var max = (w > y) ? w : y;
    var dot = 6 - max + 1;
    var temp = GCD(6, dot);
    console.log(dot / temp,"/", 6 / temp);

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

});


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

let l = 0;
rl.on('line', (input) => {
        rl.close();
        let numbers = input.split(' ').map(x=>parseInt(x))
        console.log(Math.min(Math.min(numbers[0],numbers[2]),numbers[1])*3)
});


var readline = require('readline');

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


const readline = require('readline');

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

rl.on( 'line', ( line )=>{
    rl.on( 'line', ( input )=>{
        let flag = false;
        for(let i = 0; i < line.length; i+=1){
            if( input.toLowerCase().charCodeAt(i) > line.toLowerCase().charCodeAt(i) ){
                console.log(1);
                rl.close();
                flag = true;
                break;
            }else if( input.toLowerCase().charCodeAt(i) < line.toLowerCase().charCodeAt(i) ){
                console.log(-1);
                rl.close();
                flag = true;
                break;
            }
        }
        //console.log(`Line: ${line} Input: ${input}`);
        flag || console.log(0);
        rl.close();
    });
});


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

readline.question("",(w1)=>{
    readline.question("",(w2)=>{
        w1Total=0;
        w2Total=0;
        w1=w1.toUpperCase();
        w2=w2.toUpperCase();
        for (let i = 0; i < w1.length; i++) {
            w1Total+=w1.charCodeAt(i);
        }
        for (let i = 0; i < w1.length; i++) {
            w2Total+=w2.charCodeAt(i);
        }
        //w1Total==w2Total?console.log(0):w1Total>w2Total?console.log(1):console.log(-1);
        if(w1Total<w2Total) // :)
            console.log(-1)
        else if(w1Total==w2Total)
            console.log(0)
        else if(w1Total>w2Total)
            console.log(1)

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

  driver();
});

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

function driver() {
  const a = readline();
  var b = readline();

  if (a === b) {
    console.log(0);
  } else if (a > b) {
    console.log(1);
  } else if (a < b) {
    console.log(-1);
  }
}


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

  driver();
});

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

function driver() {
  const a = readline();
  var b = readline();

  a = a.toLowerCase();
  b = b.toLowerCase();

  if (a === b) {
    console.log(0);
  } else if (a > b) {
    console.log(1);
  } else if (a < b) {
    console.log(-1);
  }
}


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() {
  let str1 = readLine();
  let str2 = readLine();
  let [count1, count2] = [0, 0];
  const len = Math.max(str1.length, str2.length);
  str1 = str1.toLowerCase();
  str2 = str2.toLowerCase();

  if (str1 === str2) {
    console.log(0);
    return;
  }

  str1 = str1.padEnd(len, "A");
  str2 = str2.padEnd(len, "A");

  str1 = str1.split("").sort().join("");
  str2 = str2.split("").sort().join("");

  for (let i = 0; i < len; i++) {
    if (str1[i] !== str2[i]) {
      count1 = str1[i].charCodeAt(0);
      count2 = str2[i].charCodeAt(0);
      break;
    }
  }

  if (count1 < count2) console.log(-1);
  else console.log(1);
}


const readline = require('readline');

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

let firstWord
let secondWord
rl.on("line",(input)=>{
    if(!firstWord) {
        firstWord = (input.split(" ").toString()).toLowerCase();
        console.log(typeof(firstWord))
    }
        else {(!secondWord)
            secondWord = (input.split(" ").toString()).toLowerCase();
            if(firstWord>secondWord) console.log(1)
            else if(firstWord<secondWord)console.log(-1)
            else console.log(0)
            rl.close();
    }
    //console.log(firstWord+"  "+secondWord)

})


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 n;
function main() {
    let str1 = lines[0][0];
    let str2 = lines[1][0].toLowerCase();
    if (str1 > str2)
        print(1)
    else if (str1 < str2)
        print(-1)
    else
        print(0)
}


const readline = require('readline');

let inputs = [];
const chars = [
    'a', 'b', 'c', 'd',
    'e', 'f', 'g', 'h',
    'i', 'j', 'k', 'l',
    'm', 'n', 'o', 'b',
    'q', 'r', 's', 't',
    'u', 'v', 'w', 'x',
    'y', 'z'
];

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

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

// Excute algorithm
rl.on('close', () => {
    let firstWord = inputs[0];
    let secondWord = inputs[1];

    recognize(firstWord, secondWord)

})

/*
 ****************************
 * Devide & Conquer functions
 ****************************
 */

// Return the charcter position
function charPosition(char) {
    let low = 0
    let high = chars.length - 1
    let mid = Math.floor((low + high) / 2)

    while (low <= high) {
        mid = Math.floor((low + high) / 2)
        if (chars.indexOf(char) > mid)
            low = mid + 1
        else if (chars.indexOf(char) < mid)
            high = mid - 1
        else
            return mid
    }

    return -1
}

// Recognize which one's order is greater than the other
function recognize(fWord, sWord) {

    for (let i = 0; i < fWord.length; i++) {
        const char1 = fWord[i].toLowerCase();
        const char2 = sWord[i].toLowerCase();

        if (charPosition(char1) > charPosition(char2))
            return console.log(1);
        else if (charPosition(char1) < charPosition(char2))
            return console.log(-1);
    }

    return console.log(0)
}


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

// Excute algorithm
rl.on('close', () => {
    let firstWord = inputs[0];
    let secondWord = inputs[1];

    if (firstWord < secondWord)
        console.log(-1)
    else if (firstWord > secondWord)
        console.log(1)
    else
        console.log(0)

})


const readline = require('readline');

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

rl.on('line', (firstLine) => {
  rl.on('line', (secondLine) => {
    const output = firstLine.toLowerCase() != secondLine.toLowerCase() ? -1 : 0
    console.log(output);
    rl.close();
  });
});


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

const input = [];

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

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

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

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


'use strict';

process.stdin.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
  const a = readline();
  const b = readline();
  let result = 0;
  for (let i = 0; i < a.length; i++) {
    const c1 = a.charAt(i).toLowerCase();
    const c2 = b.charAt(i). toLowerCase();
    if (c1 < c2) {
      result = -1;
    }
    if (c1 > c2) {
      result = 1;
    }
  }
  // output
  print(result);
}


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

const strs = [];

readline.on('line', line => {
  strs.push(line);
  if (strs.length === 2) {
    let aSum = 0;
    let bSum = 0;
    for (let i = 0; i < strs[0].length; i++) {
      aSum += strs[0][i].toLowerCase().charCodeAt();
      bSum += strs[1][i].toLowerCase().charCodeAt();
    }
    if (aSum === bSum) {
      console.log(0);
    } else if (aSum < bSum) {
      console.log(-1);
    } else if (aSum > bSum) {
      console.log(1);
    }
  }
});


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);
    myerr("-----start-----");
    var start = new Date();
    Main();
    var end = new Date() - start;
    myerr("----- end -----");
    myerr("Time: " + (end) + "ms");
    myerr("Memory: " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
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) {
    var returnObj = {
        list: input, index: 0, max: input.length,
        hasNext: function () { return (this.index < this.max); },
        next: function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { var returnInput = this.list[this.index]; this.index++; return returnInput; } }
    };
    return returnObj;
}
function myout(s) { console.log(s); }
function myerr(s) { console.error("debug:" + require("util").inspect(s, false, null)); }
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; } }

function Main() {
    var str1 = next();
    var str2 = next();

    myout(str1.localeCompare(str2));

} // Use Terminal to debug, not Debug Console!


const readline = require('readline');

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

let data = [];
rl.on('line', (input) => {
   data.push(input);
});

rl.on('close', () => {
   solve(data);
});

function solve(data) {

   s1 = data[0];
   s2 = data[1];

   console.log(compare(s1, s2));

}

function compare(s1, s2) {
   for (let i = 1; i < s1.length; i++) {
      s1c = s1[i].toLowerCase().charCodeAt(0);
      s2c = s2[i].toLowerCase().charCodeAt(0);
      if (s1c > s2c) {
         return 1;
      } else if (s1c < s2c) {
         return -1;
      }
   }
   return 0;
}


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 x = 0;
let s1, s2 = ""
const arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' ,'k', 'l', 'm', 'n', 'o','p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

function main(input){

	if(i == 0){
		s1 = input
		i++
		return
	}
	if(i == 1){
		s2 = input
		i++
	}

	let x = 0
	let y = 0
	for(var j = 0 ; j < s1.length ; j++){

		let v = arr.indexOf(s1[j].toLowerCase())
		let w = arr.indexOf(s2[j].toLowerCase())
		x = x + parseInt(v)
		y = y + parseInt(w)

	}
	if(y === x) {
		console.log("0")
	}
	if(x > y){
		console.log("1")
	}

	if(x < y){
		console.log("-1")
	}
}


function lexicographically(str1, str2) {
  for (let i = 0; i < str1.length; i++) {
    if (
      str1[i].toLocaleLowerCase().charAt(0) >
      str2[i].toLocaleLowerCase().charAt(0)
    ) {
      return 1;
    } else if (
      str1[i].toLocaleLowerCase().charAt(0) <
      str2[i].toLocaleLowerCase().charAt(0)
    ) {
      return -1;
    } else {
      continue;
    }
  }

  return 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 str1 = readLine().toLowerCase().split('');
	const str2 = readLine().toLowerCase().split('');

	const diff = str1.reduce((a, c, i) => {
		return a + (c.charCodeAt(0) - str2[i].charCodeAt(0));
	}, 0);

	const res = diff < 0 ? -1 : diff > 0 ? 1 : 0;
	console.log(res);
}


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

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

  // Both strings length are same.
  let flag = 0;
  for (let index = 0; index < str1.length; index++) {
    const s1 = str1[index].toLowerCase();
    const s2 = str2[index].toLowerCase();
    if (s1 === s2) {
      flag = 0;
    } else if (str1[index] > str2[index]) { // Small case alphabets has higher ASCII value. aka (a > A) = true
      flag = 1;
      break;
    } else {
      flag = -1;
      break;
    }
  }

  return flag;
}


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function readAsInt(){
  return parseInt(readline());
}

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

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

function main() {
    const s1 = readline();
    const s2 = readline();
    const getValue = c => {
      return c.toLowerCase().charCodeAt();
    }
    const getScore = s => {
      return s.split('').map(getValue).reduce((acc, v) => acc + v, 0)
    }
    const score1 = getScore(s1);
    const score2 = getScore(s2);
    console.log(score1 < score2 ? -1 : (score2 < score1 ? 1 : 0));
}


const stdin = process.openStdin();

process.stdin.on('data', function (chunk) {
  lines = chunk.toString().split('\n');
  lines.map((line, i) => processLine(line, i));
});

let scores;
let output = 0;
function processLine(text, i) {
  if (i === 0) {
    scores = text.toString().trim().split(' ').map(a => parseInt(a, 10)).sort();
    output += Math.trunc(scores[1] / 2) * scores[0];
    output += Math.trunc((scores[0] - 1) / 2);
    console.log(output);
  }
}


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

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

  const chars = [...d];
  chars.sort();
  const alpha = 'abcdefghijklmnopqrstuvwxyz';

  let ans = -1;
  const str = [chars[0]];

  for (let i = 0; i < n; i++) {
    let prev = str[str.length - 1];
    let distance = Math.abs(alpha.indexOf(prev) - alpha.indexOf(chars[i]));

    if (distance < 2) {
      continue;
    }

    str.push(chars[i]);

    if (str.length === k) {
      break;
    }
  }

  if (str.length === k) {
    ans = 0;
    for (let i = 0; i < str.length; i++) {
      ans += alpha.indexOf(str[i]) + 1;
    }
  }

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


function howMany(dim, x) {
    let amt = 0;
    for (let i = 1; i <= dim+1; i++) {
        for (let j = 1; j <= dim+1; j++) {
            if (i * j == x) amt++;
        }
    }
    return amt;
}

process.stdin.addListener("data", data => {
    const nums = data.toString().split(" ").map(n => parseInt(n));
    console.log(howMany(nums[0], nums[1]));
});


function howMany(dim, x) {
    // let pairs = [];

    let amt = 0;
    let prevFact = -1;
    const max = Math.min(x/2, dim);//Make sure both factors are in the table
    for (let i = 1; i <= max; i++) {//Find all factor pairs of X
        const pair = x / i;
        if (Math.floor(pair) == pair && pair <= dim && pair != prevFact) {//If a pair has been found
            amt++;
            // pairs.push([i, pair]);
            prevFact = i;
        }
    }
    // console.log(pairs);
    amt *= 2; //Only half the table is evaluated, to be more efficient
    return amt;
}

process.stdin.addListener("data", data => {
    const nums = data.toString().split(" ").map(n => parseInt(n));
    console.log(howMany(nums[0], nums[1]));
});


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

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

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

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


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

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

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

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


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

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

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

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


let i = ''

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

process.stdin.on('end', () => {
    const { EOL } = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/

    let inputData = lines[0].split(" ")
    let tableSize = parseInt(inputData[0])
    let desiredNumber = parseInt(inputData[1])
    let numberOfOccurance = 0

    for(i = 2; i <= tableSize ; i++) {
        if (desiredNumber % i === 0) {
            numberOfOccurance++
        }
    }

    if(desiredNumber <= tableSize) { numberOfOccurance++ }

    console.log(numberOfOccurance)
})


let i = ''

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

process.stdin.on('end', () => {
    const { EOL } = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/

    let inputData = lines[0].split(" ")
    let tableSize = parseInt(inputData[0])
    let desiredNumber = parseInt(inputData[1])
    let numberOfOccurance = 0

    for(i = 1; i <= tableSize; i++) {
        for (j = 1; j<= tableSize ; j++) {
            if (i * j == desiredNumber) {
                numberOfOccurance ++
            }
        }
    }
    console.log(numberOfOccurance)
})


'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 s = readline();
  const t = readline();
  helper(s, t);
}

function helper(s, t) {
  if (s.length < t.length) {
    console.log('need tree');
    return;
  }
  if (s.indexOf(t) > -1) {
    console.log('automaton');
    return;
  }
  let cnt = new Array(26).fill(0);
  for (let i = 0; i < t.length; i++) {
    cnt[t.charCodeAt(i) - 97]++;
  }

  for (let i = 0; i < s.length; i++) {
    cnt[s.charCodeAt(i) - 97]--;
  }

  if (cnt.every((charCnt) => charCnt <= 0))
    if (s.length === t.length) console.log('array');
    else console.log('both');
  else console.log('need tree');
}


'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 s = readline();
  const t = readline();
  helper(s, t);
}

function helper(s, t) {
    if (s.length < t.length) {
        console.log('need tree');
        return;
    }
    if (s.indexOf(t) > -1) {
        console.log('automaton');
        return;
    }
    let need_tree = false;
    let automaton = false;
    let array = false;

    let cntT = new Array(26).fill(0);
    for (let i = 0; i < t.length; i++) {
        cntT[t.charCodeAt(i) - 97]++;
    }

    let cntS = new Array(26).fill(0);
    for (let i = 0; i < s.length; i++) {
        cntS[s.charCodeAt(i) - 97]++;
    }

    for (let i = 0; i < 26; i++) {
        if (tCount[i] > sCount[i]) {
            need_tree = true;
            break;
        }
        if (tCount[i] < sCount[i]) {
            automaton = true;
        }
    }

    if (need_tree) {
        console.log('need tree');
        return;
    }

    let match = -1;
    let found = 0
    for (let i = 0; i < t.length; i++) {
        found = s.indexOf(t.charAt(i), match + 1)
        if (index_found > match) {
            match = found;
        } else {
            array = true;
            break;
        }
    }

    if (automaton && array) {
        console.log('both');
        return;
    }
    if (automaton) {
        console.log('automaton');
        return;
    }
    console.log('array');
    return;
}


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, m] = readLine().split(' ').map(Number);
    let max = Math.max(n, m);
    let loopMax = Math.round(Math.sqrt(max));
    let count = 0;
    for (let i = 0; i <= loopMax; i++) {
        for (let j = 0; j <= loopMax; j++) {
            if (i * i + j === n && j * J + i === m) {
                count++;
            }
        }
    }
    console.log(count);
}


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

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	let [n, m] = nl.nums();
	let max = Math.max(n,m);
	let cnt = 0;
	for(let i = 0; i < max; i++){
		for(let j = 0; j < max - i; j++){
			if (a*a + b === n && a + b*b === m){
				cnt++;
			}
		}
	}
	console.log(cnt);

};

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


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

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	let [n, m] = nl.nums();
	let max = Math.max(n,m);
	let cnt = 0;
	for(let a = 0; a < max; a++){
		for(let b = 0; b < max - a; b++){
			if (a*a + b === n && a + b*b === m){
				cnt++;
			}
		}
	}
	console.log(cnt);

};

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


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

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

  for(let i = 1; i <= n; i++) {
    sum += sum + i;

    if (sum >= n) {
      ans = i;
      break;
    }
  }

  console.log(ans);

});


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, a, b] = readLine().split(' ').map(Number);
    let c = n - b;
    // console.log(n - c + 1);
    // if (c === a) {
    //     console.log(n - c);
    // } else {
    //     console.log(n - c + 1);
    // }
    //
    let start = n - a;
    let end = n - start + 1;
    if (end <= b) {
        console.log(end);
    } else if (start === c) {
        console.log(n - c);
    } else {
        console.log(n - c + 1);
    }
}


const readline = require('readline');

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

const pad2 = (x) => ("0" + x).slice(-2);

const readTime = (s) => s.replace(/\r?\n|\r/, "").split(":");

rl.question("enter time1:", (time1) => {
  const [h1, m1] = readTime(time1);
  rl.question("enter time2:", (time2) => {
    const [h2, m2] = readTime(time2);
    const [A, B] = [
      new Date(0, 0, 0, h1, m1).getTime(),
      new Date(0, 0, 0, h2, m2).getTime(),
    ].sort();

    const result = new Date(A + (B - A) / 2);

    process.stdout.write(
      `${pad2(result.getHours())}:${pad2(result.getMinutes())}`
    );
  });
});


const readline = require('readline');

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

rl.on('line', input => {
  console.log(min(input.split(' ')));
  process.exit();
});

const min = input => {
  return parseInt(input.reduce((ant, act) => parseInt(ant) + parseInt(act)) / input.length);
}


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() {
    const t = Number(readLine())
    for (let _i = 0; _i < t; _i++) {
        const [n, k, l] = readLine().split(/\s/).map(Number)
        const ds = readLine().split(/\s/).map(Number)
        let result = true
        const repeats = Array(k).fill(0)
        for (const d of ds) {
          const index = d - (l - k + 1)
          if (index >= k) {
            result = false
            break
          }
          for (let i = 0; i < k; i++) {
            repeats[i] = i > index ? 0 : repeats[i] + 1
            if (repeats[i] > k - i) {
              result = false
              break
            }
          }
          if (!result) {
            break
          }
        }
      console.log(result ? 'Yes' : 'No')
    }
}


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

rl.on('line', (d) => {
  if (+d === 2) {
    console.log(3);
  }
  else {
    console.log(6);
  }

  c++;
});


var print = console.log
var readline = this.readline || require('lol-io').readline
var y = +readline() + 1
const check = (x) => (x + '').length === new Set(x + '').size
while (!check(y)) y++
print(y);


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

const daysInMonth = (month) => new Date(2017, month, 0).getDate();

rl.on('line', (data) => {
  const [m, d] = data.split(' ').map(Number);
  const days = daysInMonth(m);
  const ans = Math.ceil(days / 7);

  console.log(ans);
});


var readline = require('readline');
var  rl = readline.createInterface(process.stdin, process.stdout);
rl.prompt();
rl.on('line', function(input) {
    var ans = main(input.split(' '));
    console.log(ans);
});
function main(input){
    var m = Number(input[0]);
    var n = Number(input[1]);
    var a = Number(input[2]);
    var ans;
    ans = Math.ceil(m/a)*Math.ceil(n/a);
    return ans;
}


var a = readline().split(' ');
print(Math.ceil(a[0]/a[2])*Math.ceil(a[1]/a[2]))


const state = { stdin: Buffer.alloc(0) };
const consume = (chunk) =>
  (state.stdin = Buffer.concat(
    [state.stdin, chunk],
    state.stdin.length + chunk.length
  ));
const commit = (answer) => process.stdout.write(answer);
const main = (args) => {
  let data = state.stdin
    .toString("utf8")
    .split(" ")
    .map((e) => parseInt(e));
  //   console.log(data);
  let ss = data[0] * data[1];
  const sc = data[2] * data[2];
  if (ss < 2) commit(ss);
  commit(ss%sc);
};
process.stdin.on("data", consume).on("end", main);


const state = { stdin: Buffer.alloc(0) };
const consume = (chunk) =>
  (state.stdin = Buffer.concat(
    [state.stdin, chunk],
    state.stdin.length + chunk.length
  ));
const commit = (answer) => process.stdout.write(answer);
const main = (args) => {
  let data = state.stdin
    .toString("utf8")
    .split(" ")
    .map((e) => parseInt(e));
  // console.log(data);
  const ss = data[0] * data[1];
  const sc = data[2] * data[2];
  commit((ss % sc).toString());
};
process.stdin.on("data", consume).on("end", main);


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 [x, y, a] = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  const rem = (x * y) % (a * a);

  console.log(rem ? rem : 1);
}


/* scheme2js generated file Fri, 16 Oct 2020 16:24:07 +0800 */
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
const print = console.log
const write = (...args) => {
    process.stdout.write(args.join(' '));
}
const lines = []
rl.on('line', line => {
    lines.push(line);
});
rl.on('close', main)
let rli = 0;
function readline() {
    return lines[rli++];
}

function main() {
var BGl_rze21ze2zzscm2js1008z00;
var BGl_mze22ze2zzscm2js1008z00;
var BGl_nze23ze2zzscm2js1008z00;
var num = readline().split(" ").map(x => parseInt(x));
BGl_nze23ze2zzscm2js1008z00 = num[0];
BGl_mze22ze2zzscm2js1008z00 = num[1];
BGl_rze21ze2zzscm2js1008z00 = num[2];
(print(((((parseInt(BGl_nze23ze2zzscm2js1008z00/BGl_rze21ze2zzscm2js1008z00)))*((parseInt(BGl_mze22ze2zzscm2js1008z00/BGl_rze21ze2zzscm2js1008z00)))))));
}


function main(readline, print) {
  let a = readline().split(" ");
  console.log(a);
  print(Math.ceil(a[0] / a[2]) * Math.ceil(a[1] / a[2]));
}
 main();


const start=(main, readlineFun, printFun) => {
  if (readlineFun && printFun) {
    main(readlineFun, printFun);
    return;
  }

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

  let input = "",
    readline,
    print;

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

  process.stdin.on("end", function() {
    input = input.split("\n");
    print = function(data) {
      process.stdout.write(data + "\n");
    };
    let inputLineIndex = 0;
    readline = function() {
      return inputLineIndex >= input.length
        ? undefined
        : input[inputLineIndex++];
    };
    process.exit(main(readline, print) || 0);
  });
}
 function main(readline, print) {
  let a = readline().split(" ");
  console.log(a);
  print(Math.ceil(a[0] / a[2]) * Math.ceil(a[1] / a[2]));
}
 start(main);


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

var num = stdin[0].split(' ');
var n = parseInt(num[0]);
var m = parseInt(num[1]);
var a = parseInt(num[2]);
var na = (n - n % a) / a;
var ma = (m - m % a) / a;
if (na * a < n) na = na + 1;
if (ma * a < m) ma = ma + 1;
console.log(na * ma);


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

let a, b, c;
rl.on('line', (line) => {
    [a, b, c] = line.split(' ').map(i => parseInt(i));
}).on('close', () => {
    process.stdout.write(Math.ceil(a / c) * Math.ceil(b / c));
});


var readline = require('readline');

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

let result = 0;

const check = (n, m, a) => {
  for (let i = 1; i < Infinity; i += 1) {
    if (i >= n / a) {
      for (let j = 1; j < Infinity; j += 1) {
        if (j >= m /a) {
          return i * j;
        }
      }
    }
  }
};

rl.on('line', function (data) {
    const input = data.split(' ');
    const n = Number(input[0]);
    const m = Number(input[1]);
    const a = Number(input[2]);

    result = check(n, m, a);
});

process.stdin.on('end', () => { console.log(result); process.exit(0); });


'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(){
  var n = parseInt(readLine());
  var m = parseint(readLine());
  var a =parseInt(readLine());
  var res = 0;
  res+= Math.ceil(n%a) + Math.ceil(m%a);

console.log(res);

}


if (process.env.ANT)
{
    global.print = this.print ||
        function(){console.log([...arguments].join(' '))} ||
        require('lol-io').print;
    global.debug = function(){console.log('debug:', [...arguments].join(' '))}
    global.write = this.write || require('lol-io').write
    global.readline = this.readline || require('lol-io').readline
    main();
}
else
{
    const rl = require('readline').createInterface({ input: process.stdin,
        output: process.stdout });
    global.print = console.log
    global.debug = ()=>{};
    global.write = (...args) => {
        process.stdout.write(args.join(' '));
    }
    const lines = []
    rl.on('line', line =>{
        lines.push(line);
    });
    rl.on('close', main)
    let rli = 0;
    global.readline = ()=>lines[rli++];
}

///////////// CODE

function main(){
    let D = [];

    let s = readline();
    let t = readline();

    function test(i, m)
    {
        debug('test ', i, m)
        let is = 0, it = 0;
        if (is==i)
            is += m;
        while (it<t.length)
        {
            while (t[it]!=s[is] && is<s.length)
            {
                is++;
                if (is==i)
                    is += m;
            }
            if (is==s.length)
                return false;
            it++;
            is++;
            if (is==i)
                is += m;
        }
        return it==t.length;
    }

    function check(n){
        debug('check '+n)
        for (let i=0; i<s.length-n+1; i++)
        {
            if (test(i, n))
                return true;
        }
    }

    let l = 1, r = s.length-t.length;
    while (l+1<r)
    {
        let m = (l+r)/2;
        if (check(m))
            l = m;
        else
            r = m;
    }
    print(check(r) ? r : r-1);

}


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

const gcd = (a, b) => {
  while (b !== 0n) {
    let temp = a;
    a = b;
    b = temp % b;
  }

  return a;
};

rl.on('line', (d) => {
  let [a, b] = d.split(' ').map(BigInt);
  console.log(gcd(a, b).toString());
});


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

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

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const ax = arr[0].split(' ')
  const a1 = parseInt(ax[0])
  const a2 = parseInt(ax[1])
  const a3 = parseInt(ax[2])
  const a4 = parseInt(ax[3])

  var f = false

  if(a1 + a2 == a3 + a4) f = true
  else if(a1 + a3 == a2 + a4) f = true
  else if(a1 + a4 == a3 + a2) f = true

  if(f) console.log('YES')
  else console.log('NO')
})


//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 one = nextIntArray();
  if((one[0] + one[1] == one[2] + one[3]) ||
    (one[0] + one[2] == one[1] + one[3]) ||
    (one[0] + one[3] == one[2] + one[1])){
    myout("YES");
  }else{
    myout("NO");
  }
}


process.stdin.on('data', data => {
   data = data.toString().trim().split(" ");

   process.stdout.write(Math.ceil(parseInt(data[0]) * parseInt(data[1]) / parseInt(data[2]) / parseInt(data[2])));
});


const readline = require("readline");

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

rl.on("line", (input) => {
  const [m, n, a] = input.split(/\s+/).map((n) => parseInt(n));
  //
  const rows = Math.ceil(m, a);
  const columns = Math.ceil(n, a);
  const total = rows * columns;
  //
  console.log(total);
  process.exit();
  //
}).on("close", () => {
  process.exit();
});


function main(stdin) {
  const [n, m, a] = stdin.split(" ").map(v => parseInt(v));
  console.log({ n, m, a });
  console.log(Math.ceil(n / a) * Math.ceil(m / a));
}

main(
  require("fs")
    .readFileSync(0, "utf-8")
    .trim()
);


process.stdin.on('data', input => {
    input = String(input).split(' ');

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

    n_neded = 0;
    m_neded = 0;

    if (n % a != 0) {
        n_neded = Math.floor(n / a) + 1;
    } else {
        n_neded = Math.floor(n / a);
    }

    if (m % a != 0) {
        m_neded = Math.floor(n / a) + 1;
    } else {
        m_neded = Math.floor(n / a);
    }

    console.log(n_neded * m_neded);

   }
)


"use strict";
exports.__esModule = true;
var fs_1 = require("fs");
var lines = fs_1["default"].readFileSync('/dev/stdin').toString();
var a = lines.split(" ").map(function (x) { return parseInt(x); });
// let a = readline().split(' ');
console.log(Math.ceil(a[0] / a[2]) * Math.ceil(a[1] / a[2]));
// print("Hello World")


'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = "";
let lines = [];
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', _ => {
    lines = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
});
function readline() {
    return inputString[currentLine++];
}
function main() {
    const a = readline().split(" ").map(x => parseInt(x));
    console.log(Math.ceil(a[0] / a[2]) * Math.ceil(a[1] / a[2]));
}


define("input", ["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const doSuff = () => {
        console.log("DOING STUFF!");
    };
    exports.default = doSuff;
});
define("main", ["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    process.stdin.resume();
    process.stdin.setEncoding("utf-8");
    let inputString = "";
    let lines = [];
    let currentLine = 0;
    process.stdin.on("data", (inputStdin) => {
        inputString += inputStdin;
    });
    process.stdin.on("end", (_) => {
        lines = inputString
            .trim()
            .split("\n")
            .map((string) => {
            return string.trim();
        });
        main();
    });
    function readline() {
        return inputString[currentLine++];
    }
    function main() {
        const a = readline()
            .split(" ")
            .map((x) => parseInt(x));
        console.log(Math.ceil(a[0] / a[2]) * Math.ceil(a[1] / a[2]));
        //   doSuff()
    }
});


var __importDefault =
  (this && this.__importDefault) ||
  function (mod) {
    return mod && mod.__esModule ? mod : { default: mod }
  }
define("input", ["require", "exports"], function (require, exports) {
  "use strict"
  Object.defineProperty(exports, "__esModule", { value: true })
  const doSuff = () => {
    console.log("DOING STUFF!")
  }
  exports.default = doSuff
})
define("main", ["require", "exports", "input"], function (require, exports, input_1) {
  "use strict"
  Object.defineProperty(exports, "__esModule", { value: true })
  input_1 = __importDefault(input_1)
  process.stdin.resume()
  process.stdin.setEncoding("utf-8")
  let inputString = ""
  let lines = []
  let currentLine = 0
  process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin
  })
  process.stdin.on("end", (_) => {
    lines = inputString
      .trim()
      .split("\n")
      .map((string) => {
        return string.trim()
      })
    main()
  })
  function readline() {
    return inputString[currentLine++]
  }
  function main() {
    const a = readline()
      .split(" ")
      .map((x) => parseInt(x))
    console.log(Math.ceil(a[0] / a[2]) * Math.ceil(a[1] / a[2]))
    input_1.default()
  }
})


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


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

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

  return cantidadVertical * cantidadHorizontal;
})


'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.trim().split('\n').map(str => str.trim());

    main();
});

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

function main() {
    // const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

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

		console.log(g);

    for (let gItr = 0; gItr < g; gItr++) {
        const nmx = readLine().split(' ');

        const n = parseInt(nmx[0], 10);

        const m = parseInt(nmx[1], 10);

        const x = parseInt(nmx[2], 10);

        const a = readLine().split(' ').map(aTemp => parseInt(aTemp, 10));

        const b = readLine().split(' ').map(bTemp => parseInt(bTemp, 10));

        // let result = twoStacks(x, a, b);

        // ws.write(result + "\n");
    }

    // ws.end();
}


function solve(n) {
  let rest = n;
  let count = 0;
  while (rest > 0) {
    rest -= Math.max(...rest.toString().split(""));
    count += 1;
  }
  return count;
}

function* main() {
  const n = parseInt(yield);
  const r = solve(n);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null
      })
      .on("line", line => q.next(line));
  })();
}

exports.solve = solve;


function check9(n) {
  const ns = n.toString();
  const indexOf9 = ns.indexOf("9");
  if (indexOf9 < 0) {
    return 0;
  }
  const rest = n % 10 ** (ns.length - indexOf9 - 1);
  const count = Math.floor(rest / 9);
  return count + 1;
}

function solve(n) {
  let rest = n;
  let count = 0;
  while (rest > 9) {
    const count9 = check9(rest);
    if (count9 > 0) {
      rest -= count9 * 9;
      count += count9;
    } else {
      rest -= Math.max(...rest.toString().split(""));
      count += 1;
    }

    // console.log(rest, count, count9)
  }
  return count + 1;
}

function* main() {
  const n = parseInt(yield);
  const r = solve(n);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null
      })
      .on("line", line => q.next(line));
  })();
}

exports.solve = solve;


let store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];

function checkDigit(n, dig) {
  if (dig === 0 && n === 0) {
    return { count: 0, decrement: 0 };
  }
  return {
    count: 1,
    decrement: Math.max(n, dig) - n
  };
}

function splitNumber(n) {
  const digitsPow = 10 ** Math.floor(Math.log10(n));
  let first = Math.floor(n / digitsPow);
  let tail = n % digitsPow;
  return [first, tail];
}

function solveCore(n, dig = 0) {
  if (store[dig][n]) {
    return store[dig][n];
  }
  if (n < 10) {
    return (store[dig][n] = checkDigit(n, dig));
  }

  let rest = n;
  let [first, tail] = splitNumber(rest);
  let count = 0;

  while (rest > 0) {
    const r = solveCore(tail, Math.max(first, dig));
    count += r.count;
    rest -= tail + r.decrement;
    [first, tail] = splitNumber(rest);
  }

  return (store[dig][n] = { count, decrement: -rest });
}
function solve(n) {
  store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];
  const r = solveCore(n, 0);
  return r.count;
}

function* main() {
  const n = parseInt(yield);
  const r = solve(n);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null
      })
      .on("line", line => q.next(line));
  })();
}

exports.solve = solve;