'use strict';

var readline = require('readline');

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

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

async function solve(r) {
  const rbs = async () => {
    return (await r()).split(' ').filter(s => s !== '').map(BigInt);
  };
  const [n, m] = await rbs();
  if (m === 1n) return n - 1n;
  return n * (m - 1n);
}

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

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


function calNumberYear(weights) {
    let limak = parseInt(weights[0]) ;
    let bob   = parseInt(weights[1]) ;

    for(let i=1 ; i < Infinity ; i++) {
         limak = limak * 3 ;
         bob   = bob * 2 ;

         if (limak > bob) return console.log(i) ;
     }

};

const readline = require("readline");

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

rl.question('', function (weights) {

    calNumberYear(weights.split(' ')) ;
    rl.close();

});

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


"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let t1 = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let t2 = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let cnt = 0;
    for (let i = 0; i < 2; i++) if (t1[i] === 1) cnt++;
    for (let i = 0; i < 2; i++) if (t2[i] === 1) cnt++;
    if (cnt === 0) console.log(0);
    else if (cnt === 4) console.log(2);
    else console.log(1);
  }
};
solve();


const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = 1//+lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const str = lines[l++]
        output[i] = solve(str)
    }
    console.log(output.join('\n'))
// })()
})

function solve(str) {
    const base = 'A'.charCodeAt(0)
    for (let i = 2; i < str.length; i++) {
        const a = str.charCodeAt(i - 2) - base
        const b = str.charCodeAt(i - 1) - base
        const c = str.charCodeAt(i) - base
        if (((a + b) % 26) !== c) return 'NO'
    }
    return 'YES'
}


"use strict";

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

let inputString = "";
let currentLine = 0;

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

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

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const x = readline();

let matrix = [];
  for (let i = 0; i < x; i++) {

    matrix.push(
      readline()
        .split(" ")
        .map((x) => +x)
    );
  }

  gamesHomeGuest(matrix);
}

function gamesHomeGuest(teams) {
   let htWearGuestCount = 0;
  for (let i = 0; i < teams.length; i++) {
    const homeTeam = teams[i];

    for (let j = 0; j < teams.length; j++) {
      const awayTeam = teams[j];

      if (homeTeam[0] === awayTeam[1]) htWearGuestCount++;
    }
  }
  console.log(htWearGuestCount);

  return htWearGuestCount;
}


function solve() {
   var n = Number(read());
   var i = 2;
   while (i * i <= n && (n % i)) {
      i++;
   }
   if (i * i > n) {
      write('1 ' + (n - 1));
   } else {
      var k = Math.floor(n / i);
      write('' + k + ' ' + k * (i - 1));
   }
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

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

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}


const readline = require('readline');

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

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


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

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var list = [one[0], one[1], one[2]];
  var d = one[3];
  list.sort(function(a,b){
    return a - b;
  });
  var output = Math.max(d - (list[1] - list[0]), 0) + Math.max(d - (list[2] - list[1]), 0);
  myout(output);
}


const readline = require('readline');

let inputs = [];

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

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

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

    const n = inputs[0].split(' ').map(num => parseInt(num))[0];
    let puzzles = inputs[1].split(' ').map(num => parseInt(num)).sort((a, b) => a - b);
    let result = [];

    for (let i = 0; i <= puzzles.length - n; i++) {
        result.push(puzzles[i + n - 1] - puzzles[i]);
    }

    console.log(Math.min(...result))

})


"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 answer=input[0].includes("1111111") || input[0].includes("0000000");
  if(answer){
    console.log("YES");
  } else{
    console.log("NO");
  }
});


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

let isDivisibleByFour = (str) => {
  let ans = 0;

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

  return ans % 4 === 0;
}

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

  while (!isDivisibleByFour(d)) {
    ans++;
    d = String(ans);
  }

  console.log(ans);
});


// GOOD
readline = require('readline')
rl = readline.createInterface({
  input: process.stdin
})

let lineNum = 0;
let n, v;
rl.on('line', (l) => {
  lineNum++;
  [n, v] = l.split(" ").map(x => parseInt(x));

  // fill as much as needed at the start
  let perunitCost = 1;
  let cost = v < n ? v : n-1;
  let d = 1 + cost/perunitCost;

  while (d < n) {
    perunitCost++;
    cost += perunitCost
    d++
  }
  console.log(cost)
  rl.close()
})


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

rl.on('line', (d) => {
  const [x, y, z, t1, t2, t3] = d.split(' ').map(Number);
  const stairTime = Math.abs(x - y) * t1;
  const elevatorTime = t3 * 3 + Math.abs(x - y) * t2 + Math.abs(x - z) * t2;

  if (stairTime < elevatorTime) {
    console.log('NO');
  }
  else {
    console.log('YES');
  }
});


const readline = require('readline');

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

var maxSize = 0;

rl.on('line', (s) => {
    var N = s.length;
    for (let i = 0; i < N; i++) {
        for (let counter = 1; counter <= N - i; counter++) {
            for (let j = 0; j <= N - counter; j++) {
                if (j == i) continue;
                var sub = s.substr(i, counter);
                var sub2 = s.substr(j, counter);
                if (sub == sub2) {
                    if (maxSize < counter) maxSize = counter;
                    break;
                }
            }
        }
    }
}).on('close', () => {
    console.log(maxSize);
    rl.close();
});


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

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

  let input = '',
    readline,
    print;

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

  process.stdin.on('end', function() {
    input = input.split('\n');
    print = function(data) {
      process.stdout.write(data + '\n');
    };
    let inputLineIndex = 0;
    readline = function() {
      return inputLineIndex >= input.length ? undefined : input[inputLineIndex++];
    };
    process.exit(main(readline, print) || 0);
  });
}
 function main(readline, print) {
  const x = parseInt(readline());
  print(Math.floor(x / 5) + (x % 5 > 0 ? 1 : 0));
}
 start(main);


/**
 * Problem - http://codeforces.com/contest/1064/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 input = readLine();

    inputArray = input.split(' ').map(Number);
    inputArraySum = inputArray.reduce((acc, currentValue) => acc + currentValue, 0);
    let maxSide = Math.max(...inputArray);

    process.stdout.write(String(Math.max(2 * maxSide - inputArraySum + 1, 0)));

    process.exit();
}


const readline = require('readline');

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

function readLines(number, cb) {
    const lines = [];
    rl.on('line', function(line) {
        lines.push(line);
        if (lines.length === number) {
            rl.close();
            cb(lines);
        }
    });
};

function readLines(number, cb) {
    const lines = [];
    rl.on('line', function(line) {
        lines.push(line);
        if (lines.length === number) {
            rl.close();
            cb(lines);
        }
    });
};

function doIt(lines) {
    const n = parseInt(lines[0]);
    const w = Math.ceil(Math.sqrt(n));
    let h = 1;
    while (h*w < n) {
        h++
    }
    console.log(w+h);
}

readLines(1, doIt);


let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var n = lines[i];
        var a = new Map();
        for(j = 1; j * j <= n; j++){
            a.set(j * j, 1);
        }
        for(j = 1; j * j * j <= n; j++){
            a.set(j * j * j, 1);
        }
        console.log(a.size);
    }
});


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 arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  const map = {};
  let count = 0;
  arr.forEach((n) => {
    if (!map[n]) map[n] = 1;
    else count++;
  });

  console.log(count);
}


process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = 1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        main()
        process.exit(0)
    }
})

function main() {
    let num = Number(inputArr[0]), sum = num
    while (num >= 10) {
        sum = 0
        while (num > 0) {
            sum += num % 10
            num = Math.floor(num / 10)
        }
        num = sum
    }
    console.log(sum)
}


const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var n,m,a;
rl.on('line', (line) => {
  [n,m,a]=line.split(' ');
}).on('close',()=>{
  var ans=Math.ceil(n/a)*Math.ceil(m/a);
  console.log(ans);
});


const readline = require('readline')

async function algo() {
  let n = await int()
  let bills = 0
  ;[100, 20, 10, 5, 1].forEach(x => {
      bills += Math.floor(n / x)
      n = n % x
  })
  console.log(bills)
}

// read the input
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))

algo()


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

const input = [];
readLine.on('line', line => input.push(line));
const bears = () => {
    let  [limak, bob] = input[0].split(' ').map(x => +x);
    let count = 0;
    for (limak, bob; limak <= bob; limak*= 3, bob *= 2) {
        count++;
    }
    console.log(count);
};

readLine.on('close', bears);


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

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

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


let fs = require('fs');
let txt = fs.readFileSync(0, "utf-8").split(/[\n\r]/).filter(data => data.length > 0);
let ind, tab;
for (let i = 0; i < txt.length; i++) {
    ind = -Infinity;
    tab = [];
    let data = txt[i].split(" ").filter(data => data.length > 0).map(data => data * 1);
    doit(data.shift(), ...data.sort((a, b) => b - a));
}

function doit(n, a, b, c) {
    calc(n, a, b, c, 0);
    console.log(ind);
}

function calc(n, a, b, c, index) {
    if(tab.includes(n))return;

    if(n===0){
        if(index>ind)ind=index;
        return;
    }else if(n<a && n<b && n<c){
        return;
    }
    tab.push(n);
    ++index;
    if (n >= c) calc(n - c, a, b, c, index);
    if (n >= b) calc(n - b, a, b, c, index);
    if (n >= a) calc(n - a, a, b, c, index);
    return;
}


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

var idx = 0;
var out = 0;
var totalScores = 0;
var passScore = 0;
rl.on("line", (theLine) => {
        var lines = theLine.split(" ");
        width = parseInt(lines[0]);
        height = parseInt(lines[1]);
        out = (width*height)/2;

        rl.close();
        console.log(Math.trunc(out).toString());
    }
);


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const [a, b] = ipt.split(EOL).slice(0, -1)
  const c = ((+a + +b) + '').replace(/0/g, '') || 0
  const x = a.replace(/0/g, '') || 0
  const y = b.replace(/0/g, '') || 0
  const z = +x + +y
  console.log(c == z ? 'YES' : 'NO')
})


//1191A

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

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

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

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

    };
};

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


let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  var T = readLine();
  var str = readLine().split("");
  var count = [];
  for (let i = 0; i < str.length; i++) {
    let nextText = i + 1;
    if (str[i] === str[nextText]) {
      count.push(str[i]);
    }
  }
  console.log(count.length);
}


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

var input= '', readline, print;

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

process.stdin.on('end', function() {
  input = input.split('\n');
  print = function(data) {process.stdout.write(data+'\n')};
  var inputLineIndex = 0;
  readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};

  process.exit(main(...input) || 0);
});

const even = ['a', 'o', 'u', 'i', 'e'];

function minPrice(n, v) {
  var currentPrice = Math.min(v, n - 1);
  var currentLiters = Math.min(v, n - 1);

  for(var i = 2; i < n; i++) {
    if(currentLiters >= n - 1) break;

    currentLiters++;
    currentPrice += i;
  }

  return currentPrice;
}

function main(n, v) {
  arr = n.split(' ');
  console.log(minPrice(+arr[0], +arr[1]));
}

//console.log(minPrice(4, 2)); // 1 2 3 4 5 -> 2 4 7


const readline = require('readline');

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

var IsPrime = function (Num) {
    if (Num == 2)
        return true;
    if (Num < 2 || Num % 2 == 0)
        return false;
    let limit = parseInt(Math.sqrt(Num));
    for (let i = 3; i <= limit; i+=2){
        if (!(Num % i))
            return false;
    }
    return true;
}

rl.on('line', (input) => {
    let temp = input.split(' ').map(item => parseInt(item));
    let n = temp[0];
    let k = temp[1];
    let prev = 2, counter = 0;

    for (let i = 3; i < n; i++){
        if (IsPrime(i)){
          let helper = prev + i + 1;
          counter += (IsPrime(helper) && helper <= n);
          prev = i;
        }
    }
    console.log(counter >= k?"YES":"NO");
    rl.close();
});


'use strict';

const fs = require('fs');

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

function solve(n, ar) {
    ar.sort((a, b) => a - b);
    let ans = (ar[n - 1] - ar[0]) % 2 === 0 ? (ar[n - 1] - ar[0]) / 2 : -1;
    for (let i = 0; i < n; i++) {
        if (ar[i] !== ar[0] && ar[i] !== ar[n - 1] && ar[i] !== ar[0] + ans) ans = -1;
    }
    if (ans === -1) {
        ans = ar[n - 1] - ar[0];
        for (let i = 0; i < n; i++) {
            if (ar[i] !== ar[0] && ar[i] !== ar[n - 1]) ans = -1;
        }
    }

    return ans;
}

function main() {

    const nk = readLine();

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

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


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

const getPrimes = (d) => {
  const maxN = d;
  const arr = new Array(maxN + 1).fill(1);
  arr[0] = 0;
  arr[1] = 0;

  for (let i = 2; i*i <= maxN; i++) {
    if (arr[i]) {
      for (let j = i*i; j <= maxN; j += i) {
        arr[j] = 0;
      }
    }
  }

  const primes = [];

  for (let i = 0; i < arr.length; i++) {
    if (arr[i]) {
      primes.push(i);
    }
  }

  return primes;
}

rl.on('line', (d) => {
  const primes = getPrimes(+d);

  let ans = 0;

  for (let i = 6; i <= +d; i++) {
    let primeDivisors = 0;
    for (let p = 0; p < primes.length; p++) {
      if (i % primes[p] === 0) {
        primeDivisors++;
      }
    }

    if (primeDivisors === 2) {
      ans++;
    }
  }

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


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


const readline = require('readline');

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

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

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

function solve(data) {

   [n, m] = data[0].split(" ").map(x => parseInt(x));

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

}


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

let currentLine = 0;
let inputString = "";

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

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

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

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

function main() {
  var [a, b] = readLine().split(" ").map(Number);

  if (a >= 1 && b <= 10) {
    var count = 0;
    for (;;) {
      if (a > b) {
        break;
      }
      a *= 3;
      b *= 2;
      count++;
    }
    console.log(count);
  }
}


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

    let stdinInput = '';

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

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

    function main(data) {
      data = data.split('\n');
      const contestant = data[0].split(' ');
      const score = data[1].split(' ');
      const kScore = +contestant[1] - 1;
      let count = 0;
      for (let i = 0; i < score.length; i += 1) {
        if (+score[i] < 1 || +score[i] < score[kScore]) break;
        count += 1;
      }
      process.stdout.write(count + '');
    }


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++) {
    let info=txt[index].split(" ")
    subs(info[0]*1,info[1]*1)

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


let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const str = "hello";
  let j = 0;
  let pass = 0;
  const inputStr = readLine();
  for (let i = 0; i < inputStr.length; i++) {
    if (str[j] === inputStr[i]) {
      j++;
      pass++;
      if (pass === 5) break;
    }
  }
  if (pass === 5) {
    console.log("YES");
  } else {
    console.log("NO");
  }
}


let input = [];

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

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

RL.on('close', () => {
    let money = [100, 20, 10, 5, 1];
    let n = input[0];
    let count_b = 0;
    for(let i = 0; i < money.length; i++){
        while(true){
            if(n-money[i] >= 0){
                count_b++; n -= money[i];
            } else break;
        }
    }
    console.log(count_b);
});


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

rl.on("line", (d) => {
  const [start, shop1, shop2] = d.split(" ").map(Number);

  console.log(
    Math.min(
      start * 2 + shop1 + shop2,
      start * 2 + shop1 * 2,
      start * 2 + shop2 * 2,
      shop1 * 2 + shop2 * 2,
      start + shop1 + shop2
    )
  );
});


'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

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

function main() {
    const s1 = readline().toLowerCase();
    const s2 = readline().toLowerCase();
    for (let i = 0; i < s1.length; i++) {
      if (s1[i].charCodeAt() > s2[i].charCodeAt()) {
        console.log(1);
        return;
      }else if (s1[i].charCodeAt() < s2[i].charCodeAt()){
        console.log(-1);
        return;
      }
    }
    console.log(0);
}


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

let currentLine = 0;
let inputString = "";

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

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

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

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

function main() {
  var arr = readLine().split("");

  var removedDuplicate = [...new Set(arr)];

  if (removedDuplicate.length % 2 == 0) {
    console.log("CHAT WITH HER!");
  } else {
    console.log("IGNORE HIM!");
  }
}


'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 nd = readLine().split(' ').map(value => parseInt(value));
    const n = nd[0];
    const k = nd[1];
    const arr = readLine().split(' ').map(value => parseInt(value));
    if (arr[0] == 0) {
        console.log(0);
    } else {
        arr.sort((a, b) => b - a);
        var ans = arr.splice(0, k);
        // console.log(ans);
        // console.log(ans[ans.length - 1])
        for (var i = ans.length - 1; i >= 0; i--) {
            if (ans[i] == 0) ans.pop();
        }
        // console.log(ans);
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] === ans[ans.length - 1])
                ans.push(arr[i]);
        }
        console.log(ans.length);
    }
}


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.rec = function( arr , brr , firstFlag , cn ) {
    	var res , r1 , newArr , newBrr , fl , sz , i , sz1 , sz2 ;
    	if( cn > 1000 ) {
    		return -1 ;
    	}
    	if( firstFlag == false && arr.length == this.baseCaseArr.length && brr.length == this.baseCaseBrr.length ) {
    		fl = 1 ;
    		sz = arr.length ;
    		for( i = 0 ; i < sz ; i++ ) {
    			if( arr[ i ] != this.baseCaseArr[ i ] ) {
    				fl = 0 ;
    				break ;
    			}
    		}
    		sz = brr.length ;
    		for( i = 0 ; i < sz ; i++ ) {
    			if( brr[ i ] != this.baseCaseBrr[ i ] ) {
    				fl = 0 ;
    				break ;
    			}
    		}
    		if( fl == 1 ) {
    			return -1 ;
    		}
    	}
    	if( arr.length == 0 ) {
    		this.winner = 2 ;
    		return 0 ;
    	}
    	if( brr.length == 0 ) {
    		this.winner = 1 ;
    		return 0 ;
    	}
    	newArr = [] ;
    	newBrr = [] ;
    	sz1 = arr.length ;
    	sz2 = brr.length ;
    	for( i = 1 ; i < sz1 ; i++ ) {
			newArr.push( arr[ i ] ) ;
		}
		for( i = 1 ; i < sz2 ; i++ ) {
			newBrr.push( brr[ i ] ) ;
		}
    	if( arr[ 0 ] > brr[ 0 ] ) {
    		newArr.push( brr[ 0 ] ) ;
    		newArr.push( arr[ 0 ] ) ;
    	}
    	else {
    		newBrr.push( arr[ 0 ] ) ;
    		newBrr.push( brr[ 0 ] ) ;
    	}
    	r1 = this.rec( newArr , newBrr , false , cn + 1 ) ;
    	if( r1 == -1 ) {
    		res = -1 ;
    	}
    	else {
    		res = r1 + 1 ;
    	}
    	return res ;
    } ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp ;
        res = 0 ;
        this.baseCaseArr = [] ;
        for( i = 0 ; i < this.k1 ; i++ ) {
        	this.baseCaseArr.push( this.arr[ i ] ) ;
        }
        this.baseCaseBrr = [] ;
        for( i = 0 ; i < this.k2 ; i++ ) {
        	this.baseCaseBrr.push( this.brr[ i ] ) ;
        }
        this.winner = -1 ;
        res = this.rec( this.arr , this.brr , true , 0 ) ;
        if( res == -1 ) {
        	print( res );
        }
        else {
        	print( res + ' ' + this.winner );
        }
    };

    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.n = irObj.nextInt();
            this.k1 = irObj.nextInt();
            this.arr = [] ;
            for( i = 0 ; i < this.k1 ; i++ ) {
                this.arr.push( irObj.nextInt() ) ;
            }
            this.brr = [] ;
            this.k2 = irObj.nextInt();
            for( i = 0 ; i < this.k2 ; i++ ) {
                this.brr.push( 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();


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}
function main() {
    let [n, m] = readLine().split(' ').map(Number);
    let puzzles = readLine().split(' ').map(Number); //[4 4]
    // let sorted = [];
    // for (let i = 0; i < n; i++) {
    //     sorted.push(puzzles[i]);
    // }
    // sorted.sort((a, b) => a - b);
    // console.log(sorted[sorted.length - 1] - sorted[0]);
    puzzles.sort((a, b) => a - b);

    let min = 10000000000;
    // for (let i = 0; i < puzzles.length; i++) {
    //     for (j = 0; j < puzzles.length; j++) {
    //         if (i === j) {
    //             continue;
    //         }
    //         let diff = Math.abs(puzzles[i] - puzzles[j]); // puzzles [0+2 -1]
    //         if (diff < min) {
    //             min = diff;
    //         }
    //     }
    // }
    for (let i = 0; i <= m - n; i++) {
        min = Math.min(min, puzzles[i + n - 1] - puzzles[i]);
    }
    console.log(min);
}


const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
let matrix = [];
rl.on("line",(input)=>{
    let row = input.split(" ").map(Number)
    matrix.push(row)
    if(matrix[4]){
        rl.close();
        let perfectRow = 3;
        let perfectCol = 3;
        let steps = 0 ;
        let currentRow = null
        let currentCol = null
        matrix.forEach((row,index) => {
            if(row.includes(1)){
                currentRow = index+1;
                row.forEach((col,index)=>{
                    if(col==1) currentCol = index+1;
                })

            }
            if (currentRow!=perfectRow || currentCol!=perfectCol ) {
                steps = Math.abs(currentCol - perfectCol)+Math.abs(currentRow-perfectRow);
                if (steps === 6) steps = 0
            }

        });
        console.log(steps)

    }
})


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 [area1, area2, area3] = readLine().split(' ').map(Number);
    let a = Math.round(Math.sqrt((area1 * area3) / area2));
    let b = Math.round(Math.sqrt((area1 * area2) / area3));
    let c = Math.round(Math.sqrt((area2 * area3) / area1));
    console.log(4 * (a + b + c));
}


process.stdin.on("data", (d)=>{
    let data = d.toString().split(' ');
    let n = parseInt(data[0]);
    let p = parseInt(data[1]);
    let k = parseInt(data[2]);
    let answer = "";
    let left = p - k;
    if(left > 1) answer ="<< ";
    else left = 1;
    let right = p + k > n ? n : p + k;
    for(let i = left; i < p; i++) answer += `${i} `;
    answer +=`(${p}) `;
    for(let i = p + 1; i <= right; i++) answer +=`${i} `;
    if(p + k < n) answer += ">>";
    console.log(answer);
});


const readline = require("readline");

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

rl.question('', function(line) {
  let [n, k] = line.split(' ').map(x => +x);
  for (let i = 0; i < k; i++) {
    if (n % 10 > 0) {
      n--;
    }
    else {
      n /= 10;
    }
  }
  console.log(n);
});

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


const readline = require('readline')

function game23 (t, s) {
    if (t%s !== 0) return -1

    let steps = 0, rem = t/s
    while (rem > 1) {
        if (rem % 2 === 0) {
            rem /= 2
            steps++
			continue;
        }

        if (rem % 3 === 0) {
            rem /= 3
            steps++
			continue;
        }

		return -1
    }

    return steps
}

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

rl.question('', answer => {
    const nums = answer.split(' ').map(x => Number(x))
    rl.close()
    console.log(game23(nums[1], nums[0]))
})


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

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;
	let n = inputReader.readNumber();
	let result = 1;
	for(let i =2;i<n;i++){
		if(n%i==0)
		  result++;
	}
	console.log(result);

	// if(flag)
	// 	console.log("YES");
	// else
	// 	console.log("NO");
	//console.log(obj);

}

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


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

rl.on('line', (data) => {
  let [d, ...arr] = data.split(' ').map(Number).reverse();
  arr.sort((a, b) => a - b);
  let ans = 0;
  let d1 = Math.abs(arr[0] - arr[1]);
  let d2 = Math.abs(arr[1] - arr[2]);

  if (d1 < d) {
    ans += d - d1;
  }

  if (d2 < d) {
    ans += d - d2;
  }

  console.log(ans);
});


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

  for (let i = 1; i < data; i++) {
    if (i % 2 === 0 && (data - i) % 2 === 0) {
      solution = "YES";
      commit(solution);
      return;
    }
  }
  commit(solution);
};

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


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

function query(arr){
    let set = new Set(arr);
    if (set.size==1)
        return print('NO');
    print('YES');
    let left = [], last;
    for (let i=1; i<arr.length; i++)
    {
        if (arr[0]==arr[i])
            left.push(i);
        else
        {
            print('1 '+(i+1));
            last = i;
        }
    }
    for (let i=0; i<left.length; i++)
        print((last+1)+' '+(left[i]+1));

}

function main() {
    var q = +readline();
    let arr = [0,	1, 1, 1, 3, 8, 40, 180, 1260, 8064, 72576, 604800, 6652800, 68428800, 889574400, 10897286400, 163459296000, 2324754432000, 39520825344000, 640237370572800, 12164510040883200]
        return print(arr[q])
    while (q--)
    {
        var n = +readline();
        let arr = readline().split(' ').map(a=>+a);
        query(arr);
    }
}


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.num = function() {
		return Number(this.next().value);
	};
nl.nums = function() {
		return this.next().value.split(/\s/g).map(Number);
	};
nl.line = function() {
		return this.next().value;
	}

const sol = () => {
	let n = nl.num();
	let ans = [8, 4, 2, 6];
	if (n === 0){
		console.log(1);
	} else {
		console.log(ans[(n-1)%4]);
	}

};

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


// 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(' ').map(num => Number(num)).sort((a, b) => a - b);
    let midFriend = +inputs[1];
    let total = +inputs[2] - midFriend;
    total += midFriend - +inputs[0];
    return total.toString();

}


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);
  let watchedTime = 15;

  for (let i = 0; i < arr.length; i++) {
    if (watchedTime < arr[i]) {
      break;
    }
    else {
      watchedTime = arr[i];
      watchedTime += 15;
    }
  }

  console.log(Math.min(watchedTime, 90));

  c++;
});


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

/**
 *
 * @param {*} str
 * @param {*} seperator
 */
function splitter(str, seperator = '') {
    return str.trim().split(seperator);
}

/**
 *
 * @param {*} arr
 */
function strToNumArr(arr = []) {
    return arr.map(num => Number(num));
}

/**
 *
 * @param {*} num1
 * @param {*} num2
 */
function matrixArray(num1, num2) {
    return Array(num1).fill(Array(num2));
}

let log = function () {
    return Function.prototype.bind.call(console.log, console, '');
}();

function removeEmptyItem(arr, index) {
    return arr.slice(0, index).concat(arr.slice(index + 1, arr.length));
}

function range(min, max) {

    let arr = [];
    for (let index = min; index < max; index++) {
        arr.push(index);

    }
    return arr;
}

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.split('\n');
    let tCard = inputs[0].trim();
    let handCards = inputs[1].trim().split(' ');
    let rank = [2, 3, 4, 5, 6, 7, 8, 9, 'T', 'J', 'Q', 'K', 'A'];
    let suits = ['D', 'C', 'S', 'H'];
    let tCardRank = tCard[0];
    let tCardSuit = tCard[1];
    let msg = 'NO';
    for (let row of handCards) {

        // for rank
        if (tCardRank === row[0]) {
            msg = 'YES';
            break;

        }
        if (tCardSuit === row[1]) {
            msg = 'YES';
            break;
        }
    }

    return msg.toString();
}


let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    let line=buf.split(' ');
    let n=parseInt(line[0]),m=parseInt(line[1]);
    if(m!==1)
    {
        let a=BigInt(n);
        let b=BigInt(m-1);
        let ans=a*b;
        console.log(ans.toString());
    }
    else console.log(n-1);
})


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}
function main() {
    let [n, m] = readLine().split(' ').map(Number);
    let max = Math.max(n, m);
    let loopMax = Math.round(Math.sqrt(max));
    let count = 0;
    for (let i = 0; i <= loopMax; i++) {
        for (let j = 0; j <= loopMax; j++) {
            if (i * i + j === n && j * j + i === m) {
                count++;
            }
        }
    }
    console.log(count);
}


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

const main = (input) => {
	input = parseInt(input);
	var hundreds = Math.floor(input / 100);
	var counter = hundreds;
	input -= hundreds * 100;
	while(input > 0) {
		counter++;
		if (input >= 100) {
			input -= 100;
		} else if (input >= 20) {
			input -= 20;
		} else if (input >= 10) {
			input -= 10;
		} else if (input >= 5) {
			input -= 5;
		} else if (input >= 1) {
			input -= 1;
		}
	}
	console.log(counter);
}


function gcd(a, b) {
  if ((a < 0) || (b < 0)) {
    throw Error('both inputs must be non-negative');
  } else if (a === 0) {
    if (b === 0) {
      throw Error('both inputs cannot be zero');
    } else {
      return b;
    }
  } else if (b === 0) {
    return a;
  } else {
    let m = Math.min(a, b);
    for (let i = m; i > 0; i = i - 1) {
      const x = a % i;
      const y = b % i;
      if ((x === 0) && (y === 0)) {
        return i;
      }
    }
    throw Error('this should not happen');
  }
}

function solve(y, w) {
  const num_faces = 6;
  const n = num_faces - Math.max(y, w) + 1;
  const g = gcd(n, num_faces);
  const a = n / g;
  const b = num_faces / g;
  return `${a}/${b}`;
};

function main(lines) {
  const trim_lines = [];
  for (const line of lines) {
    const t = line.trim();
    if (t.length > 0) {
      trim_lines.push(t);
    }
  }
  const [line] = trim_lines;
  const [y, w] = line.split(/\s+/).map(Number);
  const result = solve(y, w);
  console.log(result);
};

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

processLinesFromStream(process.stdin, main);


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

//Don't have to see. end------------------------------------------
function Main(){
  var s = nextCharArray();
  var t = next();
  var check = "";
  while(s.length > 0){
    check += s.pop();
  }
  if(check == t){
    myout("YES");
  }else{
    myout("NO");
  }
}


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

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

function distinct(y) {
	y = y.toString(10).split('');
	let { length } = y;

	return length === [...new Set(y)].length;
}

function main() {
	let y = readLine() >> 0;
	y++;
	while (!distinct(y)) {
		y++;
	}
	console.log(y);
}


const readline = require('readline');

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

const canDivide = (aWeight) => {
  if(typeof aWeight === 'number' && aWeight >= 1 && aWeight <= 100) {
    if(aWeight % 2 === 0) {
      const dividedWeight = aWeight/2;
      if(dividedWeight > 1) {
        return 'YES'
      }
    }
  }

  return 'NO';
}

rl1.on('line', (aInput) => {
  let weight = parseInt(aInput);
  console.log(canDivide(weight));
  rl1.close();
});


const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function reverse(str) {
    return str.split("").reverse().join("");
}

rl.on('line', (input) => {
    x = input;
    x = reverse(x);
    let an = 0, one = 0;
    for (let i = 0; i < x.length; i++){
        if (i % 2 === 0)an++;
        if (x.charAt(i) === '1')one++;
    }
    if (one === 1 && x.length % 2 === 1 || one === 0 && x.length % 2 === 1)an--;
    console.log(an);
    rl.close();
});


const readline = require('readline');

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

rl.question('', (input) => {
       let x = input.split(' ');

       let y = Math.ceil(x[0] / x[2]);
       let z = Math.ceil(x[1] / x[2]);

       console.log(y * z);

       rl.close();
});


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

let stdin = '';

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

process.stdin.on('end', () => {
  const data = stdin.split('\n')[1];

  let counter = 0;
  let current;

  for (const value of data) {
    if (value === current) counter++;
    else current = value;
  }

  process.stdout.write(String(counter));
});


"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}
function getValue() {
  return parseInt(readline());
}
let mod = BigInt(1e9 + 7);
const solve = () => {
  let t = getValue();
  while (t--) {
    let [n, k] = BInpArr();
    const pow = (n, k) => {
      if (k === 0n) return 1n;
      let x = pow(n, k / 2n);
      if (k % 2n) return (n * ((x * x) % mod)) % mod;
      else return (x * x) % mod;
    };
    console.log(pow(n, k) + "");
  }
};
solve();


const input = [];

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

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

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

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

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

  console.log(sum);
});


const state = { stdin: Buffer.alloc(0) };
const consume = (chunk) =>
  (state.stdin = Buffer.concat(
    [state.stdin, chunk],
    state.stdin.length + chunk.length
  ));
const commit = (answer) => process.stdout.write(answer);
//
const main = (args) => {
  let data = parseInt(state.stdin.toString("utf8"));
  //   let solution = "NO";
  // num%2 === 0 ? num/parts+1 : num/parts
  if(data < 3) return commit("NO");
  return data % 2 === 0  && commit("YES") || commit("NO");
  //   for (let i = 1; i < data; i++) {
  //     if (i % 2 === 0 && (data - i) % 2 === 0) {
  //       solution = "YES";
  //       commit(solution);
  //       return;
  //     }
  //   }
  //   commit(solution);
};

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


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

readline.on('line', line => {
    const [w, h, k] = line.split(' ').map(x => parseInt(x));
    let result = 0;
    for (let i = 1; i <= k; i++)
        result += 2*(w - 4*(i - 1) + h - 4*(i - 1) - 2);
    console.log(result);
});


'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 n = readline();
  const p = readline();
  const m = [
    'qwertyuiop',
    'asdfghjkl;',
    'zxcvbnm,./'
  ];
  let s = [];
  for (let i = 0; i < p.length; i++) {
    for (let j = 0; j < m.length; j++) {
      let idx = m[j].indexOf(p.charAt(i));
      if (idx !== -1) {
        s.push(n === 'R' ? m[j].charAt(idx - 1) : m[j].charAt(idx + 1));
        break;
      }
    }
  }
  print(s.join(''));
}


const readline = require('readline');

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

rl.on('line', (S) => {
    let vowels = ['A', 'E', 'I', 'O', 'U', 'Y', 'a', 'e', 'i', 'o', 'u', 'y'];
    for (let i = S.length - 1; i >= 0; i--) {
        if (S[i] == '?' || S[i] == ' ')
            continue;
        if (vowels.includes(S[i])){
            console.log("YES")
            break;
        }
        else {
            console.log("NO");
            break;
        }
    }
    rl.close();
});


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

let ans = 0;
let str1, str2;
let count = 0;

rl.on('line', (str) => {
  if (count === 0) {
    str1 = str.toLocaleLowerCase();
  }
  else {
    str2 = str.toLocaleLowerCase();
  }

  count++;
});

rl.on('close', () => {
  if (str1 === str2) {
    ans = 0;
  }
  else if (str1 > str2) {
    ans = 1;
  }
  else {
    ans = -1;
  }
  console.log(ans);
})


// Problem #    : 1A
// Created on   : 2019-01-15 00:40:22
process.stdin.resume();
process.stdin.setEncoding("utf8");

var input = "",
  readline,
  print;

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

process.stdin.on("end", function() {
  input = input.split(/\r?\n/);
  print = function(data) {
    process.stdout.write(data + "\n");
  };
  var inputLineIndex = 0;
  readline = function() {
    return inputLineIndex >= input.length ? undefined : input[inputLineIndex++];
  };
  process.exit(main() || 0);
});

function main() {
  // Your code here
  let [n, m, a] = readline().split(" ");

  let x = Math.floor(n / a) + (n % a == 0 ? 0 : 1);
  let y = Math.floor(m / a) + (m % a == 0 ? 0 : 1);
  print(Math.floor(x) * Math.floor(y));

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

    main();
});

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

function main() {
    let t = Number(readline())
    while (t--) {
        let key = Number(readline())
        let doors = readline().split(' ').map(v => Number(v))
        let openedDoors = 0

        while (key != 0) {
            key = doors[key - 1]
            openedDoors += 1
        }

        if (openedDoors == 3) console.log('YES')
        else console.log('NO')
    }

}


const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
const print = console.log
const write = (...args) => {
    process.stdout.write(args.join(' '));
}
const lines = []
rl.on('line', line => {
    lines.push(line);
});
rl.on('close', main)
let rli = 0;
function readline() {
    return lines[rli++];
}

function main() {
    var y = +readline() + 1
    const check = (x) => (x + '').length === new Set(x + '').size
    while (!check(y)) y++
    write(y);
}


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

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var output = 0;
  output += Math.floor(N / 100);
  N %= 100;
  output += Math.floor(N / 20);
  N %= 20;
  output += Math.floor(N / 10);
  N %= 10;
  output += Math.floor(N / 5);
  N %= 5;
  output += N;
  myout(output);
}


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}
function main() {
    let numberString = readLine();
    // if (numberString.indexOf('4') === -1 && numberString.indexOf('1') === -1) {
    //     console.log('NO');
    //     return;
    // }
    for (let i = 0; i < numberString.length; i++) {
        if (numberString[i] !== '1' && numberString[i] !== '4') {
            console.log('NO');
            return;
        }
    }
    if (numberString[0] !== '1') {
        console.log('NO');
        return;
    }
    if (numberString.includes('444')) {
        console.log('NO');
        return;
    }
    console.log('YES');
}


// 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 weights = str.trim().split(' ');

    let limakW = +weights[0];
    let bobW = +weights[1];
    for (var i = 1; i <= 10; i++) {

        limakW *= 3;
        bobW *= 2;
        if (limakW > bobW) {
            break;
        }
    }

    return i.toString();
}


// Sample code to perform I/O:

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

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

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

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

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

// Write your code here
function nameLookUp(str) {
    let inputs = str.trim().split('\n');
    let oneNum = inputs[0].trim();
    let twoNum = inputs[1].trim();
    let num = [];
    for (let i = 0; i < oneNum.length; i++) {
        let bit = String(oneNum[i] ^ twoNum[i]);
        num.push(bit);
    }

    return num.join('').toString();
}


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 = input[0].split(' ')
	const people = parseInt(_input[0], 10)
	const pencil = parseInt(_input[1], 10)
	const notepad = parseInt(_input[2], 10)
	let check = 'No'
	if (pencil >= people && notepad >= people)
		check = 'Yes'
	console.log(check)
})


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

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

  b = +d;
  const a1 = Math.floor(Math.abs(a - b) / 2);
  const b1 = Math.ceil(Math.abs(a - b) / 2);
  const leftSum = a1 * (a1 + 1) / 2;
  const rigthSum = b1 * (b1 + 1) / 2;
  const ans = leftSum + rigthSum;

  console.log(ans);

  c++;
});


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

rl.on('line', (d) => {
  let [x, y, z] = d.split(' ').map(Number);
  let ans = '?';

  if (x > y + z) {
    ans = '+';
  }
  else if (y > x + z) {
    ans = '-';
  }
  else if (x === y && z === 0) {
    ans = '0';
  }

  console.log(ans);
});


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 => string.trim());

    main();
});

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

const s2i = s => parseInt(s, 10);

function main() {
  const k = BigInt(readLine());
  let max = 1n;
  while (max ** 10n < k) max++;
  let nMax = 10n;
  let nMin = 0n;
  while (max ** (nMax - 1n) * (max - 1n) ** (nMin + 1n) >= k) {
    nMax--;
    nMin++;
  }

  let result = '';
  const codeforces = 'codeforces'
  for(let i = 0; i < 10; i++) {
    const reps = i < nMax ? max : max - 1n;
    for (let j = 0; j < reps; j++) {
      result += codeforces.charAt(i);
    }
  }

  console.log(result)
}


// 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 nWeight = nLines[0];
    let quotient = nWeight % 2 === 0 && nWeight > 2 ? 'yes' : 'no';
    return quotient;

}


    const readline = require('readline');

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

    rl.question('', (input) => {
      const [n, m, a] = input.split(' ')
      console.log(Math.ceil(n/a) * Math.ceil(m/a));
      rl.close();
    });


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

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


process.stdin.on('data', input => {
  const inputs = input.toString().split('\n');
  const cutOffIndex = inputs[0].split(' ')[1];
  const test = inputs[1];
  const result = getNumberOfCrossedThreshold(test.split(' '), Number(cutOffIndex) - 1);
  console.log(result);
});

function getNumberOfCrossedThreshold(arr, cutOffIndex) {
  // Check if the cutoff Indey should be less than array length;
  // array length should be of 1 length;
  const cutOff = arr[cutOffIndex];
  return arr.reduce((acc, curr) => {
    // Number should be positive in order to be counted.
    // Minimum cutoff marks 0
    if (Number(curr) >= Number(cutOff) && Number(curr)) {
      ++acc;
    }

    return acc;
  }, 0);
}


const input = [];

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

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

RL.on('close', () => {
  const balls = input.pop().split(' ').map(x => parseInt(x));
  const params = input.pop().split(' ').map(x => parseInt(x));

  const [n, k] = params;

  let answer = 0;
  balls.forEach((b, i) => {
    if (b >= balls[k-1] && b > 0) { answer += 1 }
  });

  console.log(answer)
});


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

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

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

function main() {
	let prog = readLine().split('');
	let grammar = {
		H: true,
		Q: true,
		9: true,
	};

	let flag = false;

	for (let i = 0, l = prog.length; i < l; ++i) {
		if (grammar[prog[i]]) {
			flag = true;
			break;
		}
	}
	flag ? console.log('YES') : console.log('NO');
}


const input = [];

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

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

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

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

  if (str === str.toUpperCase()) {
    console.log(str.toLowerCase());
    return;
  }

  if (
    str[0].toLowerCase() === str[0] &&
    str.slice(1).toUpperCase() === str.slice(1)
  ) {
    console.log(`${str[0].toUpperCase()}${str.slice(1).toLowerCase()}`);
    return;
  }

  console.log(str);
});


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

rl.on('line', (d) => {
  const [l, n] = d;
  let ans = 8;

  if (l === 'a' || l === 'h' || n === '8' || n === '1') {
    ans = 5;
  }

  if (d === 'a1' || d === 'a8' || d === 'h1' || d === 'h8') {
    ans = 3;
  }

  console.log(ans);
});


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

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var w = one[0];
  var h = one[1];
  var two = nextIntArray();
  var three = nextIntArray();
  var u1 = two[0];
  var d1 = two[1];
  var u2 = three[0];
  var d2 = three[1];
  for(var i = h; i >= 0; i--){
    w += i;
    if(i == d1){
      w -= u1;
    }
    if(i == d2){
      w -= u2;
    }
    if(w < 0){
      w = 0;
    }
  }
  myout(w);
}


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

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

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

  let ost = a;
  while (ost >= b) {
    answ += parseInt(ost/b);
    ost = parseInt(ost/b) + (ost % b);
  }

  console.log(answ);
});


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

rc.on('line', function(i){
    const e = i % 2 === 0
    console.log((e && i >= 4) ? 'YES' : 'NO')
})


///////////////////////////////// pre-define /////////////////////////////////////
const pr = console.log;
const err = console.error;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const powmod = (a, b, mod) => {
    let r = 1n;
    while (b > 0n) {
        if (b % 2n == 1) r = r * a % mod;
        b >>= 1n;
        a = a * a % mod;
    }
    return r;
};
const counter = (a_or_s) => {
    let map = new Map();
    for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1);
    return map;
};
///////////////////////////////////////////////////////////////////////////////////

const MOD = BigInt(1e9 + 7);
const solve = (n, k) => {
    pr(powmod(n, k, MOD).toString());
};

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

main()


"use strict";

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

let inputString = "";
let currentLine = 0;

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

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

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const x = readline().split(" ");

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

  fn(x2);
}

function fn(arr) {
    console.log(arr.sort(function(a, b){return a-b}).join(" "))
}


const readline = require("readline");

let inputs = [];

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

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

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

function solution(data) {
    [a, b] = data[0].split(" ").map(Number);
    let ans = 0;
    while (a <= b) {
        ans++;
        a*=3;
        b*=2;
    }
	return ans;
};


var buffer = '';

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
        buffer += chunk;
    }
});

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

function solve() {
    buffer = buffer.trim();
    let a = 0;
    let other = 0;
    buffer.split('').forEach(element => {
        if (element === 'a'){
            a++;
        }
        else{
            other++;
        }
    });

    process.stdout.write('' + (a > other ? a + other : a * 2 - 1));
}


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

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => { inputString += inputStdin; });
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
});
function input() { return inputString[currentLine++]; }
const println = (x = "") => process.stdout.write(String(x) + "\n");
const print = x => { process.stdout.write(String(x)); }
// >>>>>>>>>>>>> Main starts here <<<<<<<<<<<<<<

const createArray = n => {
    let ar = new Array(n).fill(0);
    println(ar);
    ar = ar.map(v => new Array(n).fill(0));
    return ar;
}

function main() {
    let n = parseInt(input());
    let ar = input().split(' ').map(v => parseInt(v));
    let ans = new Array(n).fill(0);

    for (let i = n-2; i >= 0; --i) {
        let val = ar[i];
        let minus = 0;
        for (let j = 1; j <= val; ++j) {
            let pos = i + 1;
            // println("j: " + j + " pos: " + pos + " ar[pos]: " + ar[pos]);
            while (pos < n && ar[pos] < j) {
                pos += 1;
            }
            if (pos != i + 1) {
                pos -= 1;
                // println("changed:: j: " + j + " pos: " + pos + " ar[pos]: " + ar[pos]);
                ar[i] -= 1;
                ar[pos] += 1;
                // println(ar);
            }
        }
    }

    // println(ar);
    ar.forEach(v => print(v + " "));
    println();

}


'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 yourFunction(arr) {
    let squares = arr[0] * arr[1];
    return Math.floor(squares / 2);
}

//----------------------------------------------

function main() {

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

    const arr = readLine().split(' ').map(arrTemp => parseInt(arrTemp, 10));
    // console.log(arr);
    let result = yourFunction(arr);

    console.log(result);
}


process.stdin.setEncoding('utf8');

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

    if (input !== null) {
        let lowerCase = 0;
        let upperCase = 0;

        for (let i = 0; i < input.length; i++) {
            if (input[i] == input[i].toUpperCase()) upperCase++;
            else lowerCase++;
        }

        if (upperCase > lowerCase) input = input.toUpperCase();
        if (lowerCase > upperCase || lowerCase == upperCase) input = input.toLowerCase();

        process.stdout.write(`${input}\n`);
        process.exit(0);
    }
});


const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
rl.on('line', (inputString) => {
    let [x, y] = inputString.split(' ').map(v => parseInt(v));
    if (!rl.on.input) rl.on.input = [];
    rl.on.input = rl.on.input.concat([x, y]);
    if (rl.on.input.length == 6) {
        sb.apply(null, rl.on.input);
        process.exit();
    }
});

function sb(w, h, u1, d1, u2, d2) {
    for (; h >= 0; h--) {
        w += h;
        if (h == d1) w -= u1;
        if (h == d2) w -= u2;
        w = Math.max(0, w);
    }
    console.log(w);
}


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

var input= '', readline, print;

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

process.stdin.on('end', function() {
    input = input.split('\n');
    print = function(data) {process.stdout.write(data+'\n')};
    var inputLineIndex = 0;
    readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};
    process.exit(main() || 0);
});

function main()
{
    let line = readline();
    let [n, m, a] = line.split(' ').map((n) => {
        return parseInt(n);
    });

    let w = Math.floor(n / a) + (n % a === 0 ? 0 : 1);
    let h = Math.floor(m / a) + (m % a === 0 ? 0 : 1);

    print(w * h);

    return 0;
}


const readline = require('readline');

let secondLine = false;

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

let inputs = [];

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

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

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

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

    let durationsForJokes = D - neededDurationForSongs;

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


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 = getArray(inputString, '\n');

  main();
});

function getArray(str, delimiter) {
  return str
    .trim()
    .split(delimiter)
    .map((string) => {
      return string.trim();
    });
}

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

function pi(str) {
  return parseInt(str);
}

function main() {
  var n = readLine();
  if (pi(n) %2 === 0 && pi(n) > 2) {
    console.log("YES");
  } else {
    console.log("NO");
  }
}


const readline = require('readline');

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

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

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

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

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

    return true;
}

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


function main() {
    // write code here:
    var arr=stdin.splice('\n').map(a => a.split(' '));
    for(let i=0;i<arr.length;i++){
        for(let j=0;j<arr[i].length;j++){
            if(arr[i][j]==='1'){
                var step=Math.abs(i-2)+Math.abs(j-2);
            }
        }
    }
    console.log(step);

}

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