var fs = require('fs')
var pb = fs.readFileSync(0, {encoding: "utf8"}); // STDIN_FILENO = 0
pb = pb.split(" ").map(x=>x*1);
console.log(Math.ceil(pb[0]/pb[2])*Math.ceil(pb[1]/pb[2]))


const readline = require('readline');

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

let numberOfStones;
let arrOfStones;
let previousElement;
let counter = 0;
rl.on("line", (input) => {
    if (!numberOfStones) {
        numberOfStones = parseInt(input.split(" "))
       // console.log(numberOfStones, typeof (numberOfStones))
    } else {
        arrOfStones = input.split(" ").toString();
     //   console.log(arrOfStones, typeof (arrOfStones))
        for (let i = 0; i < arrOfStones.length; i++) {
            const currentElement = arrOfStones[i];
            if (!previousElement) {
                previousElement = currentElement;
                continue;
            } else {
                previousElement = arrOfStones[i-1];
                if (previousElement == currentElement) {
                    counter++
                }
                else continue ;

            }

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

})


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

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

    if (line.indexOf("+") == -1) {
        console.log(line);
    } else {
        var a = line.split("+");
        i = 0;
        while (i <= a.length){
            for (var j = 0; j< a.length; j++){
                if (a[j]> a[j+1]) {
                    var aux = a[j];
                    a[j] = a[j+1];
                    a[j+1] = aux;
                }
            }
            i++;

        }
        var s="";
        for (var j = 0; j< a.length; j++){
            s=s+ a[j] + "+"
        }
        console.log(s.slice(0, -1));
    }
    process.exit(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() {
  let [len, targetIndex] = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  let [leftLen, rightLen] = [0, 0];
  if (len % 2 === 0) [leftLen, rightLen] = [len / 2, len / 2];
  else [leftLen, rightLen] = [Math.floor(len / 2) + 1, len - (Math.floor(len / 2) + 1)];

  if (targetIndex <= leftLen) {
    console.log(2 * (targetIndex - 1) + 1);
  } else {
    targetIndex = targetIndex - leftLen;
    console.log(2 * targetIndex);
  }
}


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

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


'use strict';

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

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    const arr = readLine().split(' ');
    const k = Number(arr[0]);
    const n = Number(arr[1]);
    const w = Number(arr[2]);
    var total = 0;
    for (var i = 1; i <= w; i++) {
        total += (i * k);
    }
    if (total <= n) {
        console.log(0);
    } else {
        console.log(total - n);
    }
}


// https://codeforces.com/problemset/problem/977/B
// Big O:
// n: string length
// Time complexity: O(n)
// Space complexity:

const readline = require("readline");

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

let stringLength;
rl.on('line', (input) => {
    if (stringLength) {
        console.log(findMostCommonGram(input, stringLength));
        rl.close();
    } else {
        stringLength = input;
    }
});

// Problem
function findMostCommonGram(string, stringLength) {
    let mostCommonGram = "";
    let mostCommonGramOccurrences = 0;
    const gramOccurrences = {};

    for (let i = 0; i < stringLength - 1; i++) {
        const twogram = string[i] + string[i + 1];
        const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] : 0;
        const currentOcurrences = occurrences + 1;
        if (currentOcurrences > mostCommonGramOccurrences) {
            mostCommonGram = twogram;
            mostCommonGramOccurrences = currentOcurrences;
        }

        gramOccurrences[twogram] = currentOcurrences;
    }

    return mostCommonGram;
}


let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
  const { EOL, } = require('os');
  const weight = i.split(EOL);
  const val = weight[0];

  const result = ((val >= 4) && (val % 2 === 0)) ? 'YES' : 'NO';

  console.log(result);
});


function read(cb) {
  let buffer = ''
  process.stdin.on('end', () => cb(buffer))
  process.stdin.on('data', data => buffer += data.toString())
}

read(input => {
  const [a, b] = input.split(/\W/).map(Number)
  if (a === b) {
    console.log(1)
  } else {
    console.log(Math.ceil(Math.log(b/a) / (Math.log(3) - Math.log(2))))
  }
})


let input = [];

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

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

RL.on('close', () => {
    let n = parseInt(input[0]);
    let title = input[1];

    let flag = false; let count = 0; let answer = 0;
    for(let i = 0; i < n; i++){
        if(title.charAt(i) === 'x' && !flag){
            flag = true; count++;
        } else if(title.charAt(i) === 'x' && flag){
            count++;
        } else if(title.charAt(i) !== 'x' && flag){
            if(count >= 3)
                answer += count-2;
            count = 0;
            flag = false;
        }
    }
    if(flag)
        if(count >= 3)
            answer += count - 2;
    console.log(answer);
})


/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const processLikes = ({ x, y, z }) => {
  if (Math.abs(x - y) > z || z === 0) {
    if (x === y) {
      return '0';
    }

    if (x > y) {
      return '+';
    }

    return '-';
  }

  return '?';
};

readline.on('line', (line) => {
  const [x, y, z] = line.split(' ').map(Number);

  console.log(processLikes({ x, y, z }));
});


let inputString = '';
let currentLine = 0;

const runMain = () => {
  inputString = inputString.trim().split('\n').map(string => string.trim());
  main();
  process.exit();
}
const readLine = () => inputString[currentLine++];

process.stdin.on('data', inputStdin => inputString += inputStdin);
process.stdin.on('end', runMain);
process.on('SIGINT', runMain);

function main() {
  let [n, k] = readLine().split(' ').map(num => Number(num));
  while (k--) {
    if (n % 10 === 0) {
      n /= 10;
    } else {
      n -= 1;
    }
  }
  console.log(n);
}


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

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

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

  let cntOne = 0, cntZero = 0;
  const nums = input[1].split(' ').map(x => parseInt(x));
  nums.forEach(x => x === 0 ? cntZero += 1 : cntOne += 1);

  let max = cntZero;

  for (let i = 0; i < nums.length; i += 1) {
    let tmpSumZero = 0, tmpSumOne = 0;
    for (let j = i; j < nums.length; j += 1) {
      for (let k = i; k <= j; k += 1)
        nums[k] === 0 ? tmpSumZero += 1 : tmpSumOne += 1;

      if (max < cntOne - tmpSumOne + tmpSumZero) max = cntOne - tmpSumOne + tmpSumZero;
      tmpSumZero = 0; tmpSumOne = 0;
    }
  }
  console.log(max);
});


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main(){

    var n = readline();
    var a = readline().split(" ").map(x=> parseInt(x));
    a.sort((x,y) => x-y);

    let c = 0;
    for(let i=0;i<n;++i){
        if(a[i]){
            let tmp = a[i];
            for(let j=i;j<n;++j){
                if(a[j]%tmp==0)
                    a[j]=0;
            }
            c++;
        }
    }
    console.log(c);

}


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let w = readline();
    if(w > 1 && (w-2)>0 && (w-2) %2 == 0 )console.log("YES");
    else console.log("NO");
}


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

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

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

  for (let i = 0; i < arr.length; i++) {
    let curr = arr[i];
    if (curr !== 0) {
      arr[i] = 0;
      ans++;

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

  console.log(ans);

  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 givenYearNumber = parseInt(readLine());
    while (true) {
        givenYearNumber++;
        let firstDigit = parseInt(givenYearNumber / 1000);
        let SecondDigit = parseInt((givenYearNumber / 100) % 10);
        let ThirdDigit = parseInt((givenYearNumber / 10) % 10);
        let LastDigit = givenYearNumber % 10;
        if (
            firstDigit !== SecondDigit &&
            firstDigit !== ThirdDigit &&
            firstDigit !== LastDigit &&
            SecondDigit !== ThirdDigit &&
            SecondDigit !== LastDigit &&
            ThirdDigit !== LastDigit
        ) {
            break;
        }
    }
    console.log(givenYearNumber);
}


let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStd) => {
  inputString += inputStd;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let [len, time] = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  let arr = readLine().split("");
  while (time--) {
    for (let i = 0; i < len - 1; i++) {
      if (arr[i] === "B" && arr[i + 1] === "G") {
        [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];
        i++;
      }
    }
  }
  console.log(arr.join(""));
}


const readline = require('readline');

const elevatorOrStairs = (data) => {
  let arry = data.split(' ');
  let x = arry[0],
    y = arry[1],
    z = arry[2],
    t1 = arry[3],
    t2 = arry[4],
    t3 = arry[5];

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

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

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

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


function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp , k , l , str1 , str2 ;
        res = 0 ;
        len = this.s.length ;
        lim = Math.floor( ( len + this.k ) / 2 ) ;
        for( l = 1 ; l <= lim ; l++ ) {
        	for( i = 0 ; i < len + this.k ; i++ ) {
        		str1 = '' ;
        		for( j = i ; j < i + l && j < len + this.k ; j++ ) {
        			if( j >= len ) {
        				str1 += 'a' ;
        			}
        			else {
        				str1 += this.s.charAt( j ) ;
        			}
        		}
        		if( str1.length == l ) {
        			str2 = '' ;
	        		for( j = i + l ; j < i + 2 * l && j < len + this.k ; j++ ) {
	        			if( j >= len ) {
	        				if( j - l < len ) {
	        					str2 += this.s.charAt( j - l ) ;
	        				}
	        				else {
	        					str2 += 'a' ;
	        				}
	        			}
	        			else {
	        				str2 += this.s.charAt( j ) ;
	        			}
	        		}
	        		if( str2.length == l && str1 == str2 ) {
	        			res = l * 2 ;
	        			break ;
	        		}
        		}
        	}
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.s = irObj.nextString();
            this.k = irObj.nextInt();
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();


// Sample code to perform I/O:

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

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

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

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

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

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

    let inputs = str.trim().split(' ');
    let currentShoesIndex = [...new Set(inputs)].length;
    let shoesToBuy = 4 - currentShoesIndex;
    return shoesToBuy.toString();
}


const readline = require('readline')

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

rl.on("line", main)
let m = 0
let n = 0
function main(input){
	const mxn = input.split(' ')

	m = mxn[0]
	n = mxn[1]

	a = m*n

	if(a%2 !== 0){
		console.log((a-1)/2)
	}
	else{
		console.log(a/2)
	}

}


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 input = lines[0].split(" ").map(value => {
        return parseInt(value)
    })

    let aCount = input[0]
    let bCount = input[1]
    let abCount = input[2]

    if (bCount > aCount) {
        let maximumACount = aCount
        let maximumBCount = aCount + 1
        let maximumABCountSeperated = abCount * 2
        let maximumLength = maximumACount + maximumBCount + maximumABCountSeperated
        console.log(maximumLength)
    } else if (bCount < aCount) {
        let maximumACount = bCount + 1
        let maximumBCount = bCount
        let maximumABCountSeperated = abCount * 2
        let maximumLength = maximumACount + maximumBCount + maximumABCountSeperated
        console.log(maximumLength)
    } else if (aCount === bCount) {
        let maximumACount = aCount
        let maximumBCount = bCount
        let maximumABCountSeperated = abCount * 2
        let maximumLength = maximumACount + maximumBCount + maximumABCountSeperated
        console.log(maximumLength)
    }
})


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);
  let ans = 0;
  const max = Math.max(...arr);

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

  console.log(ans);
});


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

//Don't have to see. end------------------------------------------
function Main(){
	var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  var output = 0;
  while(A <= B){
    A *= 3;
    B *= 2;
    output++;
  }
  myout(output);
}


'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;
      break;
    }
    if (c1 > c2) {
      result = 1;
      break;
    }
  }
  // output
  print(result);
}


const stdin = process.stdin;
stdin.setEncoding('UTF-8');

stdin.on('data', (data) => {
    let arr = data.split(' ').map((x)=>{return parseInt(x);});
    console.log(Math.ceil(arr[0]/arr[2])*Math.ceil(arr[1]/arr[2]));
});


'use strict';

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let nk = readLine().split(' ').map(v => parseInt(v));
    let n = nk[0];
    let k = nk[1];
    let time = 240 - k; //240-222= 18
    let ans = 0;
    let p = 0;
    for (var i = 1; i <= n; i++) {
        p += 5 * i;
        if (p > time) break;
        else ans++;

    }
    console.log(ans);
}


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

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


const solve = (n, m, a) => {
    if (n <= a) {
        if (m <= a) {
            return 1;
        } else {
            return 1 * Math.floor(m / a);
        }
    } else {
        if (m <= a) {
            return 1 * Math.floor(n / a);
        } else {
            let ms, ns;
            if (m % a != 0) {
                ms = Math.ceil(m / a);
            } else {
                ms = m / a;
            }
            if (n % a != 0) {
                ns = Math.ceil(n / a);
            } else {
                ns = n / a;
            }
            return ms * ns;
        }
    }
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout,
        terminal: false
    });
    let input;
    rl.on('line', function (line) {
        input = line.split(" ").map(x => Number(x));
        console.log(solve(input[0], input[1], input[2]));
    });

};

main()


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

    let steps = 0;
    while(true){
        if(a+b > c && a+c > b && c+b > a)
            break;
        else {
            if(a > b && a > c && b > c)
                c++;
            else if(a > b && a > c && c >= b)
                b++;
            else if(b > c && b > a && c >= a)
                a++;
            else if(b > c && b > a && a >= c)
                c++;
            else if(c > b && c > a && a >= b)
                b++;
            else if (c > b && c > a && b > a)
            {
                a++;
            }
            steps++;
        }
    }
    console.log(steps);
});


let data = '';
process.stdin.on('data', input => data += input);
process.stdin.on('end', () => {
    const score = (arr1, arr2, n) => {
        let x = 0, y = 0;
        for (let i = 0; i < n; i++) {
            if (arr1[i] > arr2[i]) x++;
            if (arr1[i] < arr2[i]) y++;
        }
        if (x === 0) return -1;
        return Math.ceil( (y + 1) / x );
    }
    const inputStrings = data.split('\n');
    const n = parseInt(inputStrings[0], 10);
    const arr1 = inputStrings[1].split(' ').map(Number);
    const arr2 = inputStrings[2].split(' ').map(Number);
    const answ = score(arr1,arr2,n)+ '\n';
    process.stdout.write(answ);
});


function onlyUnique(value, index, self) {
    return self.indexOf(value) === index;
}
let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    //console.log(lines);
    let name = lines[0];
    var unique = Array.from(name).filter(onlyUnique);
    //console.log(unique);
    if(unique.length%2)
        console.log('IGNORE HIM!');
    else
        console.log('CHAT WITH HER!');
})


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

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

  arr.push(d.split(' ').map(Number));

  c++;
});

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

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

  if (arr.length > 3) {
    ans -= arr[0][1];
    ans -= arr[0][arr.length - 2];
    ans -= arr[arr.length - 1][1];
    ans -= arr[arr.length - 1][arr.length - 2];
    ans -= arr[1][0];
    ans -= arr[1][arr.length - 1];
    ans -= arr[arr.length - 2][0];
    ans -= arr[arr.length - 2][arr.length - 1];
  }

  console.log(ans);
});


/**
 * Problem - http://codeforces.com/contest/1084/problem/A
 */

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

var input_stdin = '';
var input_stdin_array = '';
var input_currentline = 0;

process.stdin.on('data', function (data) {
  input_stdin += data;
});

process.stdin.on('end', function () {
  input_stdin_array = input_stdin.split('\n');
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
    let numFloors = Number(readLine());
    let floors = readLine().split(' ').map(Number);
    let minCost = Number.POSITIVE_INFINITY;

    for ( let i = 0 ; i < numFloors ; i++ ) {
        let currentX = i;
        let currentCost = 0;
        floors.forEach( function( numPeople, currentFloor ) {
            currentCost = currentCost + numPeople * 2 * ( Math.abs ( currentX - currentFloor ) + Math.abs( currentFloor ) + Math.abs( -currentX ) );
        } );
        if ( currentCost < minCost ) {
            minCost = currentCost;
        }
    }
    process.stdout.write(String(minCost));
    process.exit();
}


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;
  let c = 1;

  while (sum < n) {
    let s = 0;
    for (let j = 1; j <= c; j++) {
      s += j;
    }

    sum += s;
    c++;

    if (sum > n) {
      break;
    }
    else {
      ans++;
    }
  }

  console.log(ans);

});


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

//Don't have to see. end------------------------------------------
function Main(){
  var s = next();
  var ok = new Set(["a","e","i","o","u","1","3","5","7","9"]);
  var count = 0;
  for(var i = 0; i < s.length; i++){
    if(ok.has(s[i])){
      count++;
    }
  }
  myout(count);
}


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

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

rl.on('line', (input) => {
    const numbers = input.split(" ").map(Number);
    const yellow = numbers[0];
    const blue = numbers[1];
    const red = numbers[2];
    console.log(findMaxOrnaments(yellow, blue, red));
    rl.close();
});

function findMaxOrnaments(yellow, blue, red) {
    const isYellowMinimum = yellow <= blue && yellow <= red

    if (isYellowMinimum) {
        let solutionFound = false;
        let yellowChosen = yellow;
        let blueChosen = 0;
        let redChosen = 0;
        while (!solutionFound) {
            blueChosen = 1 + yellowChosen;
            redChosen = blueChosen + 1;
            if (blueChosen > blue || redChosen > red) {
                yellowChosen = yellowChosen - 1;
            } else {
                solutionFound = true;
            }

        }
        return yellowChosen + blueChosen + redChosen;
    }

    const isBlueMinimum = blue <= yellow && blue <= red;
    if (isBlueMinimum) {
        let solutionFound = false;
        let yellowChosen = 0;
        let blueChosen = blue;
        let redChosen = 0;
        while (!solutionFound) {
            yellowChosen = blueChosen - 1;
            redChosen = blueChosen + 1;
            if (yellowChosen > yellow || redChosen > red) {
                blueChosen = blueChosen - 1;
            } else {
                solutionFound = true;
            }

        }

        return yellowChosen + blueChosen + redChosen;
    }

    let solutionFound = false;
    let yellowChosen = 0;
    let blueChosen = 0;
    let redChosen = red;
    while (!solutionFound) {
        yellowChosen = redChosen - 2;
        blueChosen = redChosen - 1;
        if (yellowChosen > yellow || blueChosen > blue) {
            redChosen = redChosen - 1;
        } else {
            solutionFound = true;
        }

    }
    return yellowChosen + blueChosen + redChosen;
}


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

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

readLine.on('close', () => {
	const _input = parseInt(input[0], 10)
	if (_input % 2 === 0) {
		console.log('Mahmoud')
	} else {
		console.log('Ehab')
	}
})


let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const b = parseInt(lines[0], 10);
  const g = parseInt(lines[1], 10);
  const n = parseInt(lines[2], 10);
  console.log(badges(b, g, n));
});

function badges(b, g, n) {
  if (n === b + g) return 1;
  const min = Math.min(b, g);
  const sub = Math.max(b, g) < n ? n - Math.max(b, g) : 0;
  return min >= n ? 1 + n - sub : 1 + min - sub;
}


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 w = parseInt(readLine());
    if (w === 2) {
        console.log('NO');
        return;
    }
    if (w % 2 === 0) {
        console.log('YES');
    } else {
        console.log('NO');
    }
}


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


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

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

const main = ([inputString]) => {
  const [height, width, tileSize] = inputString.split(' ');
  const verticalTiles = Math.ceil(height / tileSize); // 2

  const horizontalTiles =
    Math.ceil((width - tileSize) / tileSize) * verticalTiles;
  return verticalTiles + horizontalTiles;
};


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

const input = [];
readLine.on('line', line => input.push(line));
const countFunction = () => {
    let n = +input[0];
    console.log(n % 2 === 0 ? n / 2 : Math.floor(n / 2) - n );
};

readLine.on('close', countFunction);


let fs = require("fs");

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

function doit(num) {
   let r=Math.floor(num/5);
   if(num%5!==0){
       ++r;
   }
   console.log(r);

}


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 s = readLine().split('');
	let t = readLine();
	if (s.reverse().join('') === t) console.log('YES');
	else console.log('NO');
}


const readline = require("readline");

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

rl.question('', (number) => {
  console.log(cal(parseInt(number))) ;
  rl.close();
});

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

function cal(num){
  let res = [] ;
  for(let i=1 ; i<=Math.ceil(num/2) ; i++) {
    if(num % i === 0) res.push(i) ;
  }
  return res.length ;
}


const readline = require('readline')

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

rl.on('line', line => {
  const [a, b] = line.split(' ').map(v => parseInt(v, 10))
  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', (l) => {
  let count = 0;
  for (let x = 0; x < l.length; x++) {
    if (l.charAt(x) === 'Q') {
      for (let y = x+1; y < l.length; y++) {
        if (l.charAt(y) === 'A') {
          for (let z = y+1; z < l.length; z++) {
            if (l.charAt(z) === 'Q') {
              count++;
            }
          }
        }
      }
    }
  }
  console.log(count)
  rl.close();
})


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

rl.on("line",(name) => {
  const n = parseInt(name)

  if(n % 2 == 0 && n > 2 ){
    console.log("YES");

  }else{
    console.log("NO")
  }
  process.exit()
});


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

//Don't have to see. end------------------------------------------
function Main(){
  var K = nextInt();
  var L = nextInt();
  var M = nextInt();
  var D = nextInt();
  var N = nextInt();
  var output = 0;
  for(var i = 1; i <= N; i++){
    if(i % K == 0 || i % L == 0 || i % M == 0 || i % D == 0){
      output++;
    }
  }
  myout(output);
}


"use strict";
let input = [];
const readline=require('readline');
const RL=readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
RL.on('line', (line)=>{
  input.push(line.trim());
});
RL.on('close', ()=>{
  const [n, m] = input[0].split(' ').map((str)=>{
    return parseInt(str);
  })

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


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}
function main() {
    let n = parseInt(readLine());
    let pagesInWeekDays = readLine().split(' ').map(Number);
    // while (result < 100) {
    //     result = result +
    // }
    function recursion(totalpagesPerWeak) {
        // console.log(totalpagesPerWeak);
        // let [
        //     monday,
        //     tuseday,
        //     wednessday,
        //     thursday,
        //     friday,
        //     saturday,
        //     sunday,
        // ] = pagesInWeekDays;

        for (let i = 0; i < pagesInWeekDays.length; i++) {
            totalpagesPerWeak = totalpagesPerWeak + pagesInWeekDays[i];
            if (totalpagesPerWeak >= n) {
                // console.log(totalpagesPerWeak);
                console.log(i + 1);
                return;
            }
        }
        if (!(totalpagesPerWeak >= n)) {
            // console.log(n);
            // console.log(totalpagesPerWeak);
            // totalpagesPerWeak = n - totalpagesPerWeak; // 1
            recursion(totalpagesPerWeak);
        }
    }
    recursion(0);
}


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

// var getline;
var input = "";
var read;
var writeline = (x) => process.stdout.write(x + "\n");
var write = (x) => process.stdout.write(x);

process.stdin.on("data", (chunk) => input += chunk);
process.stdin.on("end", () => {
    // input = input.split(/\r?\n/);
    // getline = () => input.shift();
    input = input.trim().split(/\s+/);
    read = () => input.shift();
    process.exit(main() || 0);
});

function main() {
    let l;
    while ((l = read()) !== undefined) {
        let x = parseInt(l);
        if (x === 0 || (x > 2 && x % 2 === 0)) {
            writeline('YES')
        } else {
            writeline('NO')
        }
    }
    return 0;
}


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:n, 1:k} = {...input[0].split(' ')};
    n = parseInt(n); k = parseInt(k);
    //2 red, 5 green, 8 blue
    //k pages
    let n_b = n*8; let n_r = 2*n; let n_g = 5*n;
    let answer = 0;
    answer += Math.ceil(n_b/parseFloat(k));
    answer += Math.ceil(n_r/parseFloat(k));
    answer += Math.ceil(n_g/parseFloat(k));

    console.log(answer);
});


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

rl.on('line', (d) => {
  const [n, k] = d.split(' ').map(Number);
  const reminder = (n + 1) % k;
  const ans = reminder !== 0 ? k - reminder + n + 1 : n + 1;
  console.log(ans);
});


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    readline();
    const arr = readline().split(' ').map(x => parseInt(x)).sort((a,b) => a - b)
    console.log(arr.join(' '))
}


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));
    let lengthRes = 0;
    lengthRes += 2*input[2];
    if(input[0]>input[1])
        return console.log((2*(input[1]+input[2]))+1);
    else if(input[0]<input[1])
        return console.log((2*(input[0]+input[2]))+1);
    else
    return console.log((2*(input[0]+input[2])));
});


// Sample code to perform I/O:

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

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

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

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

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

// Write your code here
function nameLookUp(arr) {
    let nLines = arr.split('\n');
    let contestantArr = nLines[0].trim().split(' ');
    let scoresArr = nLines[1].trim().split(' ');
    let kScore = scoresArr[parseInt(contestantArr[1]) - 1];
    let count = 0;
    for (let i = 0; i < scoresArr.length; i++) {

        if (+scoresArr[i] > 0 && +scoresArr[i] >= kScore) {
            count++;
        }
    }
    return count.toString();

}


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

rl.question('', (numbers) => {
  console.log(doit(numbers.split(' ')));
  rl.close();
});

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

const doit = (numbers) => ((+numbers[1] / +numbers[0]) >= 1 && (+numbers[2] / +numbers[0]) >= 1) ? "Yes" : "No";


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

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


'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++];
}
/**
4
22
9999
1
777

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = parseInt(readline());

    let start = 1;
    let count = 0;

    while(start < n % 10) {
    	count += 1 + 2 + 3 + 4;
    	start++;
    }

    start = 1;
    while(start <= (""+ n).length) {
    	count += start;
    	start++;
    }

    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 [x, y] = nl.nums();
	if (y%x !== 0){
		console.log(-1);
	} else {
		let a = y/x;
		let cnt = 0;
		while(a%2 === 0){
			cnt++;
			a /= 2;
		}
		while(a%3 === 0){
			cnt++;
			a /= 3;
		}
		console.log((a === 1)?cnt:-1);
	}

};

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


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 fileNameLength = lines[0]
    let fileName = lines[1]
    let newFileName = buildNewFileName(fileName)
    let omittedCharactersCount = fileNameLength - newFileName.length
    console.log(omittedCharactersCount)
})

function buildNewFileName(fileName) {
    let explodedName = fileName.split("")

    let xCount = 0
    let newFileName = "";
    explodedName.forEach(element => {
        if (element === 'x') {
            xCount++;
        } else {
            xCount = 0
        }

        if (xCount < 3) {
            newFileName += element
        }
    });
    return newFileName
}


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

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

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

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


const readline = require('readline');

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

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

function check(num) {

    if (parseInt(num) % 7 === 0 ||
        parseInt(num) % 4 === 0 ||
        parseInt(num) % 47 === 0)
        return console.log("YES")
    else {
4
        const nums = num.split('');

        for (let i = 0; i < nums.length; i++) {

            if (nums[i] != 4 && nums[i] != 7)
                return console.log("NO")
        }

        return console.log("YES")

    }

}


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

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

const main = ([inputString]) => {
  const [n, k] = inputString.split(' ');
  let ans = n;
  for (let i = 0; i < k; i += 1) {
    const str = String(ans);
    const endingDigit = str[str.length - 1];
    if (endingDigit === '0') {
      ans = ans / 10;
    } else {
      ans -= 1;
    }
  }
  return String(ans);
};


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

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

const main = ([inputString]) => {
  let vowelsStripped = inputString
    .toLowerCase()
    .replace(/(a|e|i|o|u|y)/g, '');
  let ans = '';
  for (let i = 0; i < vowelsStripped.length; i += 1) {
    ans += `.${vowelsStripped[i]}`;
  }
  return ans;
};


process.stdout.write("");

process.stdin.on('data', function(data) {
    process.stdout.write(data % 2 == 0 && data != 2 ? "YES" : "NO");
    process.exit();
});


var DEBUG = false;
var { EOL } = require('os');
var fs = require('fs');

var r = process.stdin;
if (DEBUG) {
  r = fs.createReadStream('input');
}
var data = '';
r.on('data', c => (data += c));
r.on('end', () => {
  var lines = data.split(EOL);
  var arr = [];
  var d;
  [arr[0], arr[1], arr[2], d] = lines[0].split(' ').map(Number);
  arr.sort(function(a, b) {
    return a - b;
  });
  var res = Math.max(0, d - (arr[1] - arr[0]));
  res += Math.max(0, d - (arr[2] - arr[1]));
  console.log(res);
});


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

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

const petya = () => {
   let a =  input[0].toLowerCase();
   let b = input[1].toLowerCase();
    if (a > b) {
        console.log(1);
    }
    else if (b > a) {
        console.log(-1);
    }
    else {
        console.log(0);
    }
};

readLine.on('close', petya);


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

for (let i = 0; i <= 100; i++) {
  if (can[i]) {
    can[i + 3] = 1;
    can[i + 7] = 1;
  }
}

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

  if (can[+d]) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  // let n = +d;
  // let ans = 'NO';

  // while (n > 0) {
  //   if (n % 7 === 0) {
  //     ans = 'YES';
  //     break;
  //   }

  //   if (n % 3 === 0) {
  //     ans = 'YES';
  //     break;
  //   }

  //   n -= 7;
  // }

  // n = +d;
  // while (n > 0) {
  //   if (n % 7 === 0) {
  //     ans = 'YES';
  //     break;
  //   }

  //   if (n % 3 === 0) {
  //     ans = 'YES';
  //     break;
  //   }

  //   n -= 3;
  // }

  // console.log(ans);

  c++;
});


const input = [];

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

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

function solver(n, m) {
  let first = 0, second = 0, copyN = n;
  let point = (m % 2 === 0) ? m : m + 1;

  while (copyN !== point/2) {
    if (copyN > point/2) {
      first += copyN - (point/2);
      copyN = point/2;
    }
    if (copyN < point/2) { copyN *= 2;  first += 1; }
  }
  first += (m % 2 === 0) ? 1 : 2;

  copyN = n;
  while (copyN !== m) {
    if (copyN < m) copyN *= 2;
    else {
      second += copyN - m;
      break;
    }
    second += 1;
  }

  return Math.min(first, second);
}

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

  const nums = new Set();
  let arr = [n]; let answ = 0;
  while (true) {
    const data = [];
    for (let i = 0; i < arr.length; i += 1) {
      const x = arr[i];

      if (!nums.has(x - 1) && x - 1 >= 1) {
        if (x - 1 === m) { console.log(answ + 1); return; }
        data.push(x-1);
        nums.add(x - 1);
      }

      if (!nums.has(x * 2) && x * 2 <= m + 100) {
        if (x * 2 === m) { console.log(answ + 1); return; }
        data.push(x * 2);
        nums.add(x * 2);
      }
    }

    arr = data;
    answ += 1;
  }
});


"use strict";
//////////// LIBS
Object.defineProperty(exports, "__esModule", { value: true });
class IO {
    constructor() {
        this.lines = [];
        this.tokens = [];
        this.lines = require('fs').readFileSync(0, 'utf8').split('\n');
    }
    getTokens() {
        if (!this.tokens.length) {
            this.tokens = this.nextLine().split(' ');
        }
        return this.tokens;
    }
    nextLine() {
        return this.lines.shift().trim();
    }
    nextNum() {
        return Number(this.getTokens().shift());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
}
function solve(n, k) {
    const mod = 1e9 + 7;
    let ret = 1;
    while (k--) {
        ret = (ret * n) % mod;
    }
    console.log(ret);
}
function main() {
    const io = new IO();
    let t = io.nextNum();
    while (t--) {
        let n = io.nextNum();
        let k = io.nextNum();
        solve(n, k);
    }
}
main();


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

function solve(){
    const n = +(readLine());
    let a = [], b = [];
    let suma = 0, sumb = 0;
    for(let i = 0; i < n; i++){
        let line = readLine();
        a.push(+(line[0]));
        b.push(+(line[2]));
        suma += a[i];
        sumb += b[i];
    }
    let check = (s,t) => s%2 == 0 && t%2 == 0;
    let bool = false;
    if(check(suma, sumb)){
        console.log(0);
        return;
    }
    for(let i = 0; i < n; i++){
        let at = suma, bt = sumb;
        at -= a[i];
        bt -= b[i];
        at += b[i];
        bt += a[i];
        if(check(at, bt)){
            console.log(1);
            return;
        }
    }
    console.log(-1);
}


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

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

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

  for (let i = 0; i <= arr.length - n; i++) {
    let v = arr[i + n - 1] - arr[i];
    ans = Math.min(v, ans);
  }

  console.log(ans);

  c++;
});


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

	if (s < n) console.log(-1);
	else console.log(c);
}


const input = [];

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

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

RL.on('close', () => {
  const set = new Set();
  input[0].split(' ').forEach(x => set.add(x));

  console.log(4 - set.size);
});


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

let l = 0;
rl.on('line', (input) => {
    rl.close();
    let inp = input.split("")
    let res = ""
    if (inp.length >= 2 && inp.length % 2 === 1) {
        res += inp[Math.floor((inp.length / 2))]
    } else if (inp.length >= 2 && inp.length % 2 === 0) {
        res += inp[Math.floor((inp.length / 2) - 1)]
    }
    let ln = inp.length % 2 === 1 ? inp.length / 2 : inp.length / 2
    ln = Math.floor(ln)
    let inc = inp.length % 2 === 1 ? 0 : 1
    for (let i = 1; i < ln; i++) {
        res += inp[ln + i - inc]
        res += inp[ln - i - inc]
    }
    res += inp[inp.length - 1]
    if (inp.length > 1 && inp.length % 2 == 1) {
        res += inp[0]
    }
    console.log(res)
    return 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 checkBeautifullYear(y) {
    let k = String(y);
    let arr = k.split('').map(value => parseInt(value));
    let p;
    for (var i = 0; i < arr.length; i++) {
        if (arr.indexOf(arr[i]) == i) {
            p = 0;
        } else {
            p = 1;
            break;
        }
    }
    if (p == 0) {
        return true;
    } else return false;
}

function main() {
    let y = readLine();
    let ans = parseInt(y) + 1;
    while (true) {
        if (checkBeautifullYear(ans) == true) {
            break;
        } else {
            ans += 1;
        }
    }
    console.log(ans);
}


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();
  const str2 = readLine();

  if (str1.split("").reverse().join("") === str2) {
    console.log("YES");
  } else {
    console.log("NO");
  }
}


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() {
  const nd = readLine().split(" ");
  const length = parseInt(nd[0], 10);
  const array = readLine()
    .split(" ")
    .map((aTemp) => parseInt(aTemp, 10));

  let count = 0;
  for (let i = 0; i < length - 1; i++) {
    for (let j = 1; j < length; j++) {
      if (array[j - 1] > array[j]) {
        [array[j - 1], array[j]] = [array[j], array[j - 1]];
      }
    }
  }
  for (let g = 0; g < array.length; g += 2) {
    if (array[g + 1] > array[g]) {
      count += array[g + 1] - array[g];
    }
  }
  console.log(count);
}

// sortTeams(length, students);

// const input = prompt("Friends");

// const meetFriends = () => {
//   let friends = input.split(" ");
//   let distance = 0;

//   for (let i = 1; i < friends.length; i++) {
//     let current = friends[i];

//     let index = i;

//     while (index >= 0 && current < friends[index - 1]) {
//       friends[index] = friends[index - 1];
//       index--;
//     }
//     friends[index] = current;
//   }
//   distance = friends[2] - friends[0];
//   console.log(distance);
// };

// meetFriends(input);

// const input1 = parseInt(prompt("First length"))
// const input2 = prompt("First text")
// const input3 = parseInt(prompt("Second length"))
// const input4 = prompt("Second text")

// const chooseTwoNumbers = () => {
//   let first = input2.split(" ");
//   let second = input4.split(" ");

//   for (let i = 1; i < input1; i++) {
//     let current = first[i];

//     let index = i;

//     while (index >= 0 && current < first[index - 1]) {
//       first[index] = first[index - 1];
//       index--;
//     }
//     first[index] = current;
//   }
//   for (let i = 1; i < input3; i++) {
//     let current = second[i];

//     let index = i;

//     while (index >= 0 && current < second[index - 1]) {
//       second[index] = second[index - 1];
//       index--;
//     }
//     second[index] = current;
//   }

//   if (
//     first[input1 - 1] >= second[input3 - 1] &&
//     first[0] >= second[input3 - 1]
//   ) {
//     console.log("YES");
//   } else if (first[input1 - 1] <= second[0] && first[0] <= second[0]) {
//     console.log("YES");
//   } else {
//     console.log("NO");
//   }
// };

// chooseTwoNumbers();


process.stdin.on('data', function(data) {
  let [n, k] = data.toString().trim().split(' ').map(Number);
  for (let i = 0; i < k; i++) {
    if (n.toString().endsWith('0')) {
      n = parseInt(n / 10);
    } else {
      n = n - 1;
    }
  }
  console.log(n);
});


'use strict';

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    inputString = inputString.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 nn = readline().split(' ');
    var n = nn[0];
    let arr = nn.slice(1);
    n = parseInt(n);

    arr = arr.map(ele => parseInt(ele))

    console.log(cutRibbon(n, arr));
}

function cutRibbon(ribbon, piecesLength) {
  let cuts = new Array(ribbon + 1).fill(0);
  cuts[0] = 0;
  piecesLength.forEach(ele => {
      cuts[ele] = 1;
  });

  for(let i = 1; i <= ribbon; i ++) {
    let cur = cuts[i];
    for(let piece of piecesLength){

    	if(piece <= i){
    	    if(cuts[i - piece] > 0){
                cur = Math.max(cur, 1 + cuts[i - piece]);
    	    }
    	}
     }

    cuts[i] = cur;
    }
  return cuts[ribbon];

}


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

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;
	var t = inputReader.readNumber();
	function print(x) { console.log(x); }
	while (t--) {
	    var n = inputReader.readNumber();
	    var cnt = 0;
	    var f = 0;
	    for (var i = 1; i <= 9; ++i) {
	        for (var j = i, time = 1; j < 10000+1; j = j * 10 + i, ++time) {
	            cnt += time;
	            if (j == n) {
	                f = 1;
	                break;
	            }
	        }
	        if (f) break;
	    }
	    print(cnt);
	}

}

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

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

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

	return {
		readNumber,
	}
}


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

rl.on('line', function(line){
    console.log(+line % 2 === 0 && line > 2 ? "YES" : "NO");
})


var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var l = 0;
    var t = +lines[l++]
    for (var i = 0; i < t; i++) {
        var arr = lines[l++].trim().split(' ').map(Number)
        console.log(solve(arr) ? 'YES' : 'NO')
    }
});

function solve([n, m, k]) {
    if (n & 1) {
        const least = m / 2
        if (k < least) return false

        if (n === 1) return true
        const r = (k - least) % (n - 1)
    // console.log(n, m, k, r)
        return !(r & 1)
    } else {
        if (m & 1) {
            const side = n / 2
            return !(k & 1) && k <= (n * m / 2 - side)
        } else {
            return !(k & 1)
        }
    }
}


function generateAlphabets() {
  var alphabets = [];
  var start = 'a'.charCodeAt(0);
  var last  = 'z'.charCodeAt(0);
  for (var i = start; i <= last; ++i) {
    alphabets.push(String.fromCharCode(i));
  }

  return alphabets;
}

const seq = generateAlphabets();

const processData = (lines) => {
  const s = lines[1].split('').map(x => x.charCodeAt(0))
  let sum = 0
  const set = Array.from(new Set(s)).sort((a, b) => a - b).reverse()
  for (const l of set) {
    const target = l - 1;
    for (let j =0; j<s.length; j++) {
      if (s[j] === l && (s[j-1] === target || s[j+1] === target)) {
        sum++
        s.splice(j, 1)
        j=-1
      }
    }
  }
  console.log(sum)
}

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


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  // input
  let a = readline().split('+').map(x => parseInt(x));
  a.sort((m, n) => m - n);
  print(a.join('+'));
}


const readline = require('readline');

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

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

function check(word) {
    const base = ['h', 'e', 'l', 'l', 'o'];
    let counter = 0;
    let next = 0;
    let temp = 0;

    contains(base[0])

    function contains(letter) {

        for (let i = temp; i < word.length; i++) {

            if (word[i] == letter) {
                counter++;
                temp = i + 1;
                next++;
                if (counter < 5)
                    return contains(base[next])
            }

            if (counter == 5) {
                return console.log("YES")
            }
        }

        return console.log("NO")

    }

}


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

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

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

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

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

let inputString = ''

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


function helpfulMaths(str) {
  let arr = str.split("+");
  arr.sort(function (a, b) {
    return a - b;
  });
  return console.log(arr.join("+"));
}

// read file
const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
let input = "";
// read each line
rl.on("line", (lineInput) => {
  input = lineInput;
});

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


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

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

    let prevStone = d[0];
    for (let i = 1; i < d.length; i++) {
        if (d[i] === prevStone) {
            ans++;
        }

        prevStone = d[i];
    }

    count++;
});

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


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, m] = readLine()
		.split(' ')
		.map(x => x >> 0);

	let c = 0;
	for (let i = 0; i <= n; i++) {
		for (let j = 0; j <= m; j++) {
			if (i * i + j === n && i + j * j === m) c++;
		}
	}

	console.log(c);
}


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

let count = 0;
let n = t = 0;

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

  let str = d.split('');
  let isSwap = 0;

  while (isSwap < t) {
    for (let j = 1; j <= n; j++) {
      let prev = str[j - 1];
      let curr = str[j];

      if (prev === 'B' && curr === 'G') {
        str[j - 1] = curr;
        str[j] = prev;
        j++;
      }
    }

    isSwap++;
  }

  console.log(str.join(''));

  count++;
});


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

//main
function main() {
    var s = readline();
    var currentValue, currentLength=0;
    for (var i=0 ; i<s.length ; i++) {
        if (s[i] === currentValue) {
            currentLength++;
            if (currentLength===7) {
                console.log("YES");
                return;
            }
        } else {
            currentValue = s[i];
            currentLength = 1;
        }
    }
    console.log("NO");
}


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

rl.on('line', (d) => {
  let [n1, n2, k1, k2] = d.split(' ').map(Number);

  if (n1 > n2) {
    console.log('First');
  }
  else {
    console.log('Second');
  }
});


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 [ab, bc, ac] = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  const b = Math.sqrt((ab * bc) / ac);
  const a = ab / b;
  const c = bc / b;

  console.log(4 * (a + b + c));
}


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

rl.on('line', (d) => {
  let [n, k] = d.split(' ').map(Number);
  const mid = Math.ceil(n / 2);

  if (mid >= k) {
    console.log(k * 2 - 1);
  }
  else {
    console.log((k - mid) * 2);
  }
});


let input ='';

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data',(data)=>input+=data)
process.stdin.on('end',()=>{
    let arr = input.split(' ').sort((a,b)=>+b - +a);

    console.log(arr[0]-arr[2])
})


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 sum = 0
        for (let i = 0; i < arr.length; i++) {
            sum += arr[i]*2*(2*(Math.max((i+1),1)-1))
        }

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


const readline = require("readline")

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

let shovelPrice;
let unlimitedBudget = 10;
let r = 0;
let flag = true;
let counter = 1;

rl.on("line", (input) => {
    if (!shovelPrice) {
        let tempArr = input.split(" ").map(Number)
        shovelPrice = tempArr[0]
        r = tempArr[1]
    }
    if (shovelPrice) {
        // if (shovelPrice === r) {
        //     console.log(counter)
        //     flag = false
        //     rl.close();
        // }
        while (flag) {
            if ((shovelPrice * counter) % unlimitedBudget === 0 || shovelPrice * counter % 10 === r) {
                console.log(counter)
                flag = false
                rl.close();
                break;
            }
            counter++
        }
    }

})


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 + (d - 1)) / 7);

  console.log(ans);
});


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

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

  return a;
}

const factorial = (n) => {
  let prev = 1;
  let r = prev;

  for (let i = 2; i <= n; i++) {
    r = prev * i;
    prev = r;
  }

  return r;
}

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

  for (let i = 1; i <= Math.min(a, b); i++) {
    ans *= i;
  }

  console.log(ans);
});


function main() {
    // write code here:
    var arr = stdin[0].split(' ').map(Number);
    var fashion = Math.min(...arr);
    var temp = Math.max(...arr) - fashion;
    var pair = 0;
    if (temp % 2 !== temp) {
        pair = Math.floor(temp / 2);
    }
    console.log(fashion + ' ' + pair);
}

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


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

let c = 0;

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

  let ans = 0;

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

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


const readline = require('readline')

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

rl.question('', ans => {
  rl.close()

  let n = Number(ans)

    function nirvana(num) {
        const str = String(num)

        function mult(str) {
            return Number(str) === 0 ? 1 : str.split('').map(x => Number(x)).reduce((i, acc = 1) => i * acc)
        }

        let l = mult(str)
        for (let i = str.length - 1; i > 0; i--) {
    		nines = str.length -1 - i + 1
    		let tMult = mult(String(Number(str.substr(0, i)) - 1))
    		tMult = tMult * (9 ** nines)

    		if (tMult > l) l = tMult
        }

    	return l
    }

  console.log(nirvana(n))
})


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[0].split(' ').map(x => parseInt(x));
  let [a, b] = nums;
  let answer = 0;

  if (a === b) { console.log(1); return }

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

  console.log(answer);
});


process.stdin.setEncoding("ascii");

let input = "";

process.stdin.on("data", data => { input += data; });
process.stdin.on("end", () => {
    const [[n, m], T] = input.trim().split("\n").map(x => x.trim().split(" ").map(Number));
    const sum = [0, ...T];
    for (let i = 1; i < sum.length; i++)
        sum[i] += sum[i - 1];
    sum.shift();
    process.stdout.write("0 ");
    for (let i = 1; i < sum.length; i++) {
        const pred = T.slice(0, i);
        pred.sort((a, b) => b - a);
        let currentSum = sum[i];
        let count = 0;
        while (currentSum > m) {
            count++;
            currentSum -= pred.shift();
        }
        process.stdout.write(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.trim().split("\n").map(string=>{
		return string.trim();
	});
	main();
});
function readLine()
{
	return inputString[currentLine++];
}
function rec(t,i,x,pre)
{
	if(i==t.length)
		return ((pre===x)?1:0);
	if(t[i]=='+')
		return rec(t,i+1,x,pre+1);
	else if(t[i]=='-')
		return rec(t,i+1,x,pre-1);
	else
		return (rec(t,i+1,x,pre-1)+rec(t,i+1,x,pre+1));
}
function main()
{
	var s=readLine().trim();
	var t=readLine().trim();
	var x=0,po=0;
	for(let i=0;i<s.length;++i)
	{
		if(s[i]=='+')
			x++;
		else
			x--;
		if(t[i]=='?')
			po++;
	}
	po=Math.pow(2,po);
	var nu=rec(t,0,x,0);
// 	console.log(nu);
	console.log(nu/po);
}


'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 sol(n, m, a) {
	let width = n;
	let height = m;

	let wCount = 0;

	while (width > a) {
		wCount += parseInt(width / a);
		width = width % a;
	}

	if (width > 0) {
		wCount++;
	}

	let hCount = 1;
	height = height - a;

	while (height > a) {
		hCount += parseInt(height / a);
		height = height % a;
	}

	if (height > 0) {
		hCount++;
	}

	// console.log(wCount * hCount);
	return wCount * hCount;

}

// sol(12,12,4)

function main() {

		const inputArr = readLine().split(' ');;

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

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

		const a = parseInt(inputArr[2], 10);

		const ans = sol(n, m, a);

		console.log(ans);
}


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

var idx = 0;

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

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


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

let first = true;
let n, t, s;

rl.on('line', (line) => {
    if (first) {
        // We're getting the numbers
        const input = line.split(' ');
        input.forEach(char => Number(char));
        n = input[0], t = input[1];
        first = false;
        return;
    } else {
        // We're getting the string
        s = line;
    }

    console.log(solution(n, t, s));
});

function solution(numberOfChildren, seconds, arrangement) {
    const q = arrangement.split('');
    for (let i = 0; i < seconds; i++) {
        for (let j = 0; j < q.length - 1; j++) {
            if (q[j] === 'B' && q[j + 1] === 'G') {s
                q[j] = 'G', q[j + 1] = 'B';
                j += 1;
            }
        }
    }
    return q.join('');
}


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 name = readLine();
  const map = name.split("").reduce((obj, char) => {
    if (!obj[char]) obj[char] = 1;
    return obj;
  }, {});
  if (Object.keys(map).length % 2 === 0) console.log("CHAT WITH HER!");
  else console.log("IGNORE HIM!");
}


let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    for(j = 1; j <= t; j++){
        var s = 0;
        var n = lines[j];
        for(k = 0; k < n; k++){
            s += s + 1;
        }
        console.log(s);
    }
});


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

let s = "";

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

process.stdin.on("end", function() {
  console.log(solve(s));
});

function solve(s) {
  const [x, y, z] = s.split(" ").map(Number);

  if (x - y == 0 && z == 0) {
    return '0';
  }
  if (Math.abs(x - y) <= z) {
    return '?';
  }
  if (x - y > 0) {
    return '+';
  }
  if (x - y < 0) {
    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', () => {
    inputString = inputString.trim().split('\n').map(str => str.trim());
    solve();
});
let readLine = () => inputString[currentLine++];

function solve(){
    const n = +(readLine());
    let str = readLine();
    let arr = [], arr2 = [];

    for(let i = 0; i < 2*n; i++){
        if(i < n)
            arr.push(+(str[i]));
        else
            arr2.push(+(str[i]));
    }
    arr.sort((a, b) => a-b);
    arr2.sort((a, b) => a-b);
    let a = true, b = true;

    for(let i = 0; i < n; i++){
        if(arr[i] <= arr2[i])
            a = false;
        if(arr[i] >= arr2[i])
            b = false;
    }
    console.log(a ^ b ? "YES" : "NO");
}


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

rl.on('line', (str) => {
    const obj = {};

    [...str].forEach(s => {
        if (!obj[s]) {
            obj[s] = s;
        }
    });

    if(Object.keys(obj).length % 2 === 0) {
        console.log('CHAT WITH HER!');
    }
    else {
        console.log('IGNORE HIM!');
    }
});


const readline = require('readline');

const r1= readline.createInterface({
	input: process.stdin,
	output: process.stdout
})
r1.on('line', (line) => {
	watermelon(+line);
	r1.close();
})

function watermelon(kg) {
	let max = 4;
	while (max <= kg) {
		if (max=== kg) {
			console.log('YES')
			return;
		}
		max += 2
	}
	console.log('NO')
}


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

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

readLine.on('close', () => {
  let [n, k] = input[0].split(' ').map(x => +x);
  for (let i = 0; i < k; i++) {
    if (n % 10 == 0) {
      n /= 10;
    }
    else {
      n--;
    }
  }
  console.log(n);
});


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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let str = readLine().split(" ")
    str[0] = parseInt(str[0])
    str[1] = parseInt(str[1])
    str[2] = parseInt(str[2])

    let tot = 0, res = 0
    for (let i = 1; i < str[2]+1; i++) {
        tot += (i * str[0])
    }

    res = tot - str[1]

    if (res < 0) console.log(0)
    else console.log(res)

}


'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 bills = [ 1, 5, 10, 20, 100 ].reverse();

  let n = parseInt(readline());
  let i = 0;
  while (n > 0) {
    //console.log(n, bills.find(b => n >= b));
    n -= bills.find(b => n >= b);
    i++;
  }
  console.log(i);
}


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

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

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

const print = console.log

solve()