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 [x, y] = d.split(' ').map(Number);
  let r = x - y;

  if (r === 0) {
    console.log(0);
  }
  else if (r % 2 !== 0 && r < 0) {
    console.log(1);
  }
  else if (r % 2 === 0 && r < 0) {
    console.log(2);
  }
  else if (r % 2 !== 0 && r > 0) {
    console.log(2);
  }
  else if (r % 2 === 0 && r > 0) {
    console.log(1);
  }

  c++;
});

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

});

'use strict';

let n = parseInt(readline());

while ( n-- > 0 ) {
  let line = readline().split(' ').map(data => parseInt(data));
  print(solve(...line));
}

function solve(x, y) {
  let diff = x - y;
  if ( diff === 0 ) {
    return 0;
  } else if ( diff < 0 ) {
    diff = Math.abs(diff);
    return ( diff % 2 === 1 ) ? 1 : 2;
  } else {
    return ( diff % 2 === 1 ) ? 2 : 1;
  }
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var one = myconv(next(),4);
        var a = one[0];
        var b = one[1];
        if(a == b){
            output[i] = 0;
        }else{
            if(a < b && a % 2 == 1 && b % 2 == 0){
                output[i] = 1;
            }
            if(a < b && a % 2 == 0 && b % 2 == 1){
                output[i] = 1;
            }
            if(a < b && a % 2 == 0 && b % 2 == 0){
                output[i] = 2;
            }
            if(a < b && a % 2 == 1 && b % 2 == 1){
                output[i] = 2;
            }

            if(a > b && a % 2 == 1 && b % 2 == 0){
                output[i] = 2;
            }
            if(a > b && a % 2 == 1 && b % 2 == 1){
                output[i] = 1;
            }
            if(a > b && a % 2 == 0 && b % 2 == 0){
                output[i] = 1;
            }
            if(a > b && a % 2 == 0 && b % 2 == 1){
                output[i] = 2;
            }
        }
    }
    myout(myconv(output,9));
}

t = +readline();
while(t--) {
    line = readline().split(" ");
    a = +line[0];
    b = +line[1];
    if(a===b) {
        print(0);
    }
    else if(a>b) {
        print((a-b)%2 + 1);
    }
    else {
        print((b-a)%2===0 ? 2 : 1);
    }
}

T=+readline();

while(T--){
    line=readline().split(" ");
    a=+line[0];
    b=+line[1];

    x=b-a;

    if (x<0){
        x=-x;
        if (x%2===0){
            print(1);
        }
        else{
            print(2);
        }
    }

    else if (x > 0) {
        if (x % 2 == 1) {
            print(1);
        }
        else {
            print(2);
        }
    }
    else {
        print(0);
    }
}

function solve(a,b) {
    var d;
    if (a == b)
        return 0;
    if (a > b) {
        d = a-b;
        return d % 2 == 0 ? 1 : 2;
    }
    d = b-a;
    return d % 2 == 0 ? 2 : 1;
}
var t = Number(readline());
while (t--) {
    var arr = readline().split(' ').map(Number);
    var a = arr[0];
    var b = arr[1];
    print(solve(a,b));
}

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

  main();
})

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

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

    for (var i = 0; i < n; i++) {
      const [a, b] = readline().split(' ');
      process.stdout.write(getStepsNumber(a, b) + '\n');
    }
}

const getStepsNumber = (a, b) => {
  if (+a === +b) {
    return 0;
  } else if ( +a < +b ) {
    if (((+b) - (+a)) % 2 === 0) {
      return 2;
    }
    return 1;
  }

  if (((+a) - (+b)) % 2 === 1) {
    return 2;
  }
  return 1;
}

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
state = 0;
rl.on('line', line => {
  if (state > 0) {
    line
      .split(' ')
      .map(Number)
      .reduce((a, b) => {
        let e = b - a;
        if (e == 0) {
          console.log('0');
        } else if ((e % 2 == 0 && e < 0) || (e % 2 != 0 && e > 0)) {
          console.log('1');
        } else {
          console.log('2');
        }
      });
  }
  state++;
}).on('close', () => {
  process.exit(0);
});

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

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

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main(arr)
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt(a, i) {
  if(i === undefined) return parseInt(a.shift())
  else return parseInt(a[i])
}

function readInts(a, i) {
  if(i === undefined) return arr.shift().split(' ').map(a => parseInt(a))
  else return arr[i].split(' ').map(a => parseInt(a))
}

function main(input) {
  let ptr = 0
  let t = readInt(input, ptr++)
  while(t--) {
    let [a,b] = readInts(input, ptr++)
    if(a === b) wr(0)
    else if(a < b) {
      if((b - a) % 2 === 0) wr(2)
      else wr(1)
    }
    else {
      if((a - b) % 2 === 0) wr(1)
      else wr(2)
    }
  }
}

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

    function foo (data) {
        const [a, b] = data;
        if (a > b) {
            if ((a - b)%2) return 2;
            else return 1;
        }
        if (a < b) {
            if ((b - a)%2) return 1;
            else return 2;
        }
        return 0;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount].split(" ").map(Number);

        let result = foo(data);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})

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

function main(lines) {
    let t, a;
    t = parseInt(lines[0]);
    for (let i = 1; i < t + 1; i++) {
        a = lines[i].split(' ');
        if (a[0] - a[1] == 0) {
            console.log(0)
        } else if ((a[0] - a[1] < 0 && (a[0] - a[1]) % 2 != 0) || (a[0] - a[1] > 0 && (a[0] - a[1]) % 2 == 0)) {
            console.log(1)
        } else {
            console.log(2)
        }
    }

}

const main = (input) => {

    input.next();

    for(let val of input){
        const [a, b] = val.split(' ').map(x => +x.trim());

        const answer = numberOfMoves(a,b);
        console.log(answer);
    }

}

const numberOfMoves = (a, b) => {

    let ans;

    const diff = Math.abs(a - b);

    ans = a == b ? 0 : 1 ;

    ans = b > a & diff % 2 == 0 ?  2 : ans;
    ans = a > b & diff % 2 == 1 ? 2 : ans;

    return ans;
}

let data = '';

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

process.stdin.on('end',() => {
    data = data.trim().split('\n');
    const input = iterator(data);
    main(input);
});

function* iterator(args){
    for(let i=0; i<args.length; i++){
        yield args[i];
    }
}

"use strict";
exports.__esModule = true;
//===============================
//===============================
var str = "", lines = [], idxLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (x) { str += x; });
process.stdin.on('end', function () {
    lines = str.trim().split('\n').map(function (x) { return x.trim(); });
    main();
});
function readline() {
    return lines[idxLine++];
}
//===============================
//===============================
function main() {
    var t = parseInt(readline());
    for (var _ = 0; _ < t; _++) {
        var x = readline().split(" ").map(function (e) { return parseInt(e); });
        var a = x[0], b = x[1];
        var res = 0;
        if (a == b) {
            res = 0;
        }
        else if (a < b) {
            res = ((b - a) % 2 == 0) ? 2 : 1;
        }
        else {
            res = ((b - a) % 2 == 0) ? 1 : 2;
        }
        console.log(res);
    }
}

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

function main(){
    let tests = parseInt(readline())
    while(tests--){
        let ab = readline().split(' ').map(x => parseInt(x));
        let a = ab[0];
        let b = ab[1];

        if(a == b){
            console.log(0);
        }
        else if(a < b){
            let dif = b - a;
            if(dif & 1) console.log(1);
            else console.log(2);
        }
        else{
            let dif = a - b;
            if(dif & 1) console.log(2);
            else console.log(1);
        }
    }
}

const readline=require('readline');

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

DATA=[];
DATA_POINTER=0
rl.on("line",line=>{
    DATA.push(line);
})

rl.on("close",()=>{
    main();
})
input=()=>{
    return DATA[DATA_POINTER++];
}

print=console.log;

function main(){
    T=+input();

    while(T--){
        line=input().split(" ");
        a=+line[0];
        b=+line[1];

        x=b-a;

        if (x<0){
            x=-x;
            if (x%2===0){
                print(1);
            }
            else{
                print(2);
            }
        }

        else if (x > 0) {
            if (x % 2 == 1) {
                print(1);
            }
            else {
                print(2);
            }
        }
        else {
            print(0);
        }
    }
}

const processData = (lines) => {
  const num = +lines[0]

  for (let j=0; j<num; j++){
    const [a, b,] = lines[j+1].split(' ').map( x => +x)
    const isOdd = a%2 === b%2;
    if (a === b) {
      console.log(0)
    } else {
      if ( (isOdd && a > b) || (!isOdd && a < b) ) {
        console.log(1)
      } else {
        console.log(2)
      }
    }
  }
}

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

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const [n, ...lines] = i.split`\n`;
    for (let i = 0; i < n; i++) {
        const [a, b] = lines[i].split` `.map(Number);
        console.log(a === b ? 0 : a < b ? (b - a) % 2 ? 1 : 2 : (a - b) % 2 ? 2 : 1);
    }
});

/* eslint-disable no-plusplus, no-lonely-if, arrow-parens, no-multi-assign, no-continue, no-mixed-operators, no-restricted-syntax, guard-for-in, prefer-destructuring, no-param-reassign */

const BROWSER = false;
const BROWSER_INPUT =
`5
2 3
10 10
2 4
7 4
9 3`;

const TIME_LIMIT = 2000;

const browserTests = [
{
input:
`5
2 3
10 10
2 4
7 4
9 3`,
output:
`1
0
2
2
1`,
},
];

function solve(){
  if (BROWSER) {
    console.log(getAnswer(BROWSER_INPUT.split('\n')));

    browserTests.forEach(({ input, output }, i) => {
      console.log('-'.repeat(40));
      const t = Date.now();
      const answerNonString = getAnswer(input.split('\n'));
      const execTime = Date.now() - t;
      const isTimeout = execTime >= TIME_LIMIT;
      const answer = answerNonString.toString();
      const expected = output.toString();
      const isCorrect = answer === expected;
      console.log(`${i}: ${isCorrect} (${execTime}ms)`);
      if (!isCorrect || isTimeout) {
        console.log(`Input:\n${input.slice(0, 100)}`);
        console.log(`Expected:\n${expected}`);
        console.log(`Answer\n${answer}`);
        console.log('Answer (non-string)', answerNonString);
        if (isTimeout) {
          console.log('Time out!');
          console.log(`Execution time: ${execTime}`);
          console.log(`Expected time: ${TIME_LIMIT}`);
        }
      }
    });
  } else {
    let INPUT = ''
    process.stdin.on('data', c => INPUT += c)
    process.stdin.on('end', () => {
        const {EOL} = require('os');
        const lines = INPUT.split(EOL);
        lines.pop();
        console.log(getAnswer(lines));
    });
  }
}

const parseNumbers = str => str.split(' ').map(val => +val);

const getAnswer = (inputLines) => {
  const getminimum = (a, b) => {
    if (a === b) return 0;
    if (a > b) {
      const diff = a - b;
      if (diff % 2 === 0) return 1;
      return 2;
    }
    const diff = b - a;
    if (diff % 2 === 1) return 1;
    return 2;
  };

  const out = [];

  for (let i = 1; i < inputLines.length; i++) {
    const nums = parseNumbers(inputLines[i]);
    out.push(getminimum(...nums));
  }

  return out.join('\n');
};

solve();

function main(input) {
    var lines = input.trim().split("\n").map(function (l) { return l.trim(); });
    var t = parseInt(lines.shift(), 10);
    while (t > 0) {
        var _a = lines.shift().split(" ").map(function (v) { return parseInt(v); }), a = _a[0], b = _a[1];
        if (a === b) {
            console.log(0);
        }
        else if (a > b) {
            if ((a - b) % 2 === 0) {
                console.log(1);
            }
            else {
                console.log(2);
            }
        }
        else {
            if ((a - b) % 2 === 0) {
                console.log(2);
            }
            else {
                console.log(1);
            }
        }
        t--;
    }
}
(function () {
    var d = "";
    process.stdin.on("data", function (v) { return d += v; });
    process.stdin.on("end", function () { return main(d); });
})();

'use strict'

let t = parseInt(readline())

while (t --> 0) {
  const arr = readline().split(' ').map(n => parseInt(n))
  const a = arr[0]
  const b = arr[1]

  let ans = 0
  const diff = Math.abs(a - b)
  if (a < b) {
    if (diff % 2) ans = 1
    else ans = 2
  } else if (a > b) {
    if (diff % 2) ans = 2
    else ans = 1
  }
  print(ans)
}

'use strict'

const problem = (a, b) => {
    if (a === b) return 0;
    if (a < b) return 2 - (b - a) % 2;
    return 1 + (a - b) % 2;
}

let t = +readline()
while(t--) {
    const ab = readline().split(' ')
    print(problem(+ab[0], +ab[1]))
}

var t = readline();
while(t--) {
    var line = readline().split(" ");
    var a = line[0];
    var b = line[1];
    if(a===b) {
        print('0');
    }
    if(a>b) {
        print((a-b)%2 + 1);
    }
    else
        print((b-a)%2===0 ? 2 : 1);
}

var t = readline();
while(t--) {
    var line = readline().split(" ");
    var a = line[0];
    var b = line[1];
    if(a===b) {
        print('0');
    }
    else if(a>b) {
        print((a-b)%2 + 1);
    }
    else
        print((b-a)%2===0 ? 2 : 1);
}

var t = readline();
while(t--) {
    var line = readline().split(" ");
    var a = line[0];
    var b = line[1];
    if(a===b) {
        print(0);
    }
    else if(a>b) {
        print((a-b)%2 + 1);
    }
    else {
        print(2-(b-a)%2);
    }
}

var t = readline();
while(t--) {
    var line = readline().split(" ");
    var a = line[0];
    var b = line[1];
    if(a===b) {
        print(0);
    }
    else if(a>b) {
        print((a-b)%2 + 1);
    }
    else {
        (b-a)%2===0 ? print(2) : print(1);
    }
}

var t = readline();
while(t--) {
    var line = readline().split(" ");
    var a = line[0];
    var b = line[1];
    if(a===b) {
        print('0');
    }
    else if(a>b) {
        print((a-b)%2===0 ? 1 : 2);
    }
    else
        print((b-a)%2===0 ? 2 : 1);
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const [_, ...lines] = i.split`\n`;
    for (const input of lines) {
        const [a, b] = input.split` `.map(Number);
        if (a === b) console.log(0);
        if (a < b) console.log(b - a % 2 ? 1 : 2);
        if (b < a) console.log(a - b % 2 ? 2 : 1);
    }
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
})

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

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

    for (var i = 0; i < n; i++) {
      const [a, b] = readline().split(' ');
      process.stdout.write(getStepsNumber(a, b) + '\n');
    }
}

const getStepsNumber = (a, b) => {
  if (a === b) {
    return 0;
  } else if ( a < b ) {
    if ((b - a) % 2 === 0) {
      return 2;
    }
    return 1;
  }

  if ((a - b) % 2 === 1) {
    return 2;
  }
  return 1;
}

const main = (input) => {

    input.next();

    for(let val of input){
        console.log(val);
        continue;
        const [a, b] = val.split(' ').map(x => +x.trim());

        const answer = numberOfMoves(a,b);
        console.log(answer);
    }

}

const numberOfMoves = (a, b) => {

    let ans;

    const diff = Math.abs(a - b);

    ans = a == b ? 0 : 1 ;

    ans = b > a & diff % 2 == 0 ?  2 : ans;
    ans = a > b & diff % 2 == 1 ? 2 : ans;

    return ans;
}

let data = '';

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

process.stdin.on('end',() => {
    data = data.split('\n');
    const input = iterator(data);
    main(input);
});

function* iterator(args){
    for(let i=0; i<args.length; i++){
        yield args[i];
    }
}

const data = [];

process.stdin.on('data', (chunk) => {
     const line = chunk + '';

     data.push(line.trim());
});

process.stdin.on('end', () => {

    const input = iterator(data);

    const n = +input.next().value;

    for(let val of input){

        const args = val.split(' ');

        const a = + (args[0].trim());
        const b = + (args[1].trim());

        const answer = numberOfMoves(a,b);
        console.log(answer);
    }
});

function* iterator(args){
    for(let i=0; i < args.length; i++){
        yield args[i];
    }
}

const numberOfMoves = (a, b) => {

    let ans;

    const diff = Math.abs(a - b);

    ans = a == b ? 0 : 1 ;

    ans = b > a & diff % 2 == 0 ?  2 : ans;
    ans = a > b & diff % 2 == 1 ? 2 : ans;

    return ans;
}

const data = [];

process.stdin.on('data', (chunk) => {
     const line = chunk + '';

     data.push(line.trim());
});

process.stdin.on('end', () => {

    const n = +data[0];

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

        const [a, b] = data[i].split('').map(x => +x.trim());

        const answer = numberOfMoves(a,b);
        console.log(answer);
    }
});

const numberOfMoves = (a, b) => {

    let ans;

    const diff = Math.abs(a - b);

    ans = a == b ? 0 : 1 ;

    ans = b > a & diff % 2 == 0 ?  2 : ans;
    ans = a > b & diff % 2 == 1 ? 2 : ans;

    return ans;
}

const main = (input) => {

    input.next();

    for(let val of input){
        console.log(val);
        const [a, b] = val.split(' ').map(x => +x.trim());

        const answer = numberOfMoves(a,b);
        console.log(answer);
    }

}

const numberOfMoves = (a, b) => {

    let ans;

    const diff = Math.abs(a - b);

    ans = a == b ? 0 : 1 ;

    ans = b > a & diff % 2 == 0 ?  2 : ans;
    ans = a > b & diff % 2 == 1 ? 2 : ans;

    return ans;
}

let data = '';

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

process.stdin.on('end',() => {
    data = data.split('\n');
    const input = iterator(data);
    main(input);
});

function* iterator(args){
    for(let i=0; i<args.length; i++){
        yield args[i];
    }
}

const data = [];

process.stdin.on('data', (chunk) => {
     const line = chunk + '';

     data.push(line.trim());
});

process.stdin.on('end', () => {

    const input = iterator(data);

    const n = +input.next().value;

    for(let val of input){

        const args = val.split(' ');

        const a = + (args[0].trim());
        const b = + (args[1].trim());

        const answer = numberOfMoves(a,b) + '\n';
        process.stdout.write(answer);
    }
});

function* iterator(args){
    for(let i=0; i < args.length; i++){
        yield args[i];
    }
}

const numberOfMoves = (a, b) => {

    let ans;

    const diff = Math.abs(a - b);

    ans = a == b ? 0 : 1 ;

    ans = b > a & diff % 2 == 0 ?  2 : ans;
    ans = a > b & diff % 2 == 1 ? 2 : ans;

    return ans;
}

const data = [];

process.stdin.on('data', (chunk) => {
     const line = chunk + '';

     data.push(line.trim());
});

process.stdin.on('end', () => {

    const input = iterator(data);

    const n = +input.next().value;

    for(let val of input){

        const args = val.split(' ');

        const a = + (args[0].trim());
        const b = + (args[1].trim());

        console.log(numberOfMoves(a,b));
    }
});

function* iterator(args){
    for(let i=0; i < args.length; i++){
        yield args[i];
    }
}

const numberOfMoves = (a, b) => {

    let ans;

    const diff = Math.abs(a - b);

    ans = a == b ? 0 : 1 ;

    ans = b > a & diff % 2 == 0 ?  2 : ans;
    ans = a > b & diff % 2 == 1 ? 2 : ans;

    return ans;
}

const main = (input) => {

    input.next();

    for(let val of input){
        const [a, b] = val.split(' ').map(x => +x.trim());

        const answer = numberOfMoves(a,b);
        console.log(answer);
    }

}

const numberOfMoves = (a, b) => {

    let ans;

    const diff = Math.abs(a - b);

    ans = a == b ? 0 : 1 ;

    ans = b > a & diff % 2 == 0 ?  2 : ans;
    ans = a > b & diff % 2 == 1 ? 2 : ans;

    return ans;
}

let data = '';

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

process.stdin.on('end',() => {
    data = data.split('\n');
    const input = iterator(data);
    main(input);
});

function* iterator(args){
    for(let i=0; i<args.length; i++){
        yield args[i];
    }
}

function* rame () {
    yield 1;
    yield 2;
}

const input = rame();
console.log(input.next().value);

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const [_, ...lines] = i.split`\n`;
    for (const input of lines) {
        const [a, b] = input.split` `.map(Number);
        console.log(a === b ? 0 : a < b ? (b - a) % 2 ? 1 : 2 : (a - b) % 2 ? 2 : 1);
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const [_, ...lines] = i.split`\n`;
    for (const input of lines) {
        const [a, b] = input.split` `.map(Number);
        console.log(a === b ? 0 : Math.abs(a - b) % 2 ? 1 : 2);
    }
});


'use strict'

class SegmentTree {
    constructor(a, op, init) {
        this.init = init;
        this.op = op;
        this.n = 1 << Math.ceil(Math.log2(a.length));
        this.t = Array(2 * this.n).fill(init);
    }

    update(i, x) {
        for (this.t[i + this.n] = [ x, i ], i += this.n; i > 1; i >>= 1) {
            this.t[i >> 1] = this.op(this.t[i], this.t[i^1]);
        }
    }
}

const NK = readline().split(' ').map(Number);
const N = NK[0];
const K = NK[1];

const LRs = [];
const R = Array.from({ length: N + 1 }, () => 0);

for (let i = 1; i <= N; i++) {
    const lr = readline().split(' ');
    const l = +lr[0];
    let r = +lr[1];
    R[i] = r++;
    if (LRs[l]) LRs[l].push(i); else LRs[l] = [ i ];
    if (LRs[r]) LRs[r].push(-i); else LRs[r] = [ -i ];
}

const sti = new SegmentTree(R, (a, b) => (a[0] < b[0]) ? b : a, [ 0, 0 ]);

let k = 0;
let ans = [];
let removed = new Set();

LRs.filter(Array.isArray).forEach(lrs => {
    lrs.forEach(i => {
        if (i > 0) {
            sti.update(i, R[i]);
            return k++;
        }
        if(!removed.has(-i)) {
            sti.update(-i, 0);
            return k--;
        }
    })
    for(; k > K; k--) {
        const i = sti.t[1][1];
        sti.update(i, 0);
        ans.push(i);
        removed.add(i);
    }
})

print(ans.length);
print(ans.join(' '));

'use strict'

const SegTreeIndex = (n) => {
    const self = { n: 1 };
    while (self.n < n) self.n <<= 1;
    self.tree = Array(self.n << 1).fill(-1);
    self.index = Array(self.n << 1).fill(-1);
    for (let i = 0; i < self.n; i++) self.index[i + self.n] = i;
    for (let i = self.n - 1; i; i--) self.index[i] = self.index[i << 1];

    self.update = (i, x) => {
        i += self.n;
        self.tree[i] = x;
        while (i > 1) {
            const left = Math.min(i, i^1);
            const right = Math.max(i, i^1);
            if (self.tree[left] >= self.tree[right]) {
                self.tree[i >> 1] = self.tree[left];
                self.index[i >> 1] = self.index[left];
            } else {
                self.tree[i >> 1] = self.tree[right];
                self.index[i >> 1] = self.index[right];
            }
            i >>= 1;
        }
    }

    self.query = (a, b) => {
        let l = a + self.n;
        let r = b + self.n;
        let s = [ -1, -1 ];
        while (l < r) {
            if (r & 1) {
                r -= 1;
                const res = Math.max(s[0], self.tree[r]);
                if (res !== s[0]) s = [ self.tree[r], self.index[r] ];
            }
            if (l & 1) {
                const res = Math.max(self.tree[l], s[0])
                if (res === self.tree[l]) s = [ self.tree[l], self.index[l] ];
                l += 1;
            }
            l >>= 1;
            r >>= 1;
        }
        return s
    }
    return self;
}

const NK = readline().split(' ').map(Number);
const N = NK[0];
const K = NK[1];
const MAX = 200001;

const LRs = Array.from({ length: MAX+2 }, () => []);
const R = Array.from({ length: N+1 }, () => 0);

for (let i = 0; i < N; i++) {
    const lr = readline().split(' ').map(Number);
    const l = lr[0];
    const r = lr[1];
    LRs[l].push(i+1)
    LRs[r+1].push(-(i+1))
    R[i+1] = r;
}

const sti = SegTreeIndex(N+1)

let segcnt = 0;
let ans = [];
let removed = new Set();

for (let i = 1; i < MAX+2; i++) {
    LRs[i].forEach(idx => {
        if (idx > 0) {
            sti.update(idx, R[idx]);
            segcnt += 1;
        } else {
            const idx2 = -idx;
            if (!removed.has(idx2)) {
                sti.update(idx2, -1);
                segcnt -= 1;
            }
        }
    })
    while (segcnt > K) {
        const query = sti.query(0, N+1);
        const mx = query[0];
        const idx = query[1];
        sti.update(idx, -1);
        ans.push(idx);
        removed.add(idx);
        segcnt -= 1;
    }
}
print(ans.length);
print(ans.join(' '));

'use strict'

const nk = readline().split(' ');
const n = +nk[0], k = +nk[1];

const x = [];
for (let i = 0; i < n; i++) x.push((lr => ({ l: +lr[0], r: +lr[1] }))(readline().split(' ')))

const max = x.reduce((r, i) => r < i.r ? i.r : r, 0)
let y = Array.from({ length: max + 1 }, () => []);
for (let i = 0; i < n; i++) {
    for (let j = x[i].l; j <= x[i].r; j++) {
        y[j].push(i);
    }
}

y = y.filter(i => i.length > k);
const ans = [];

for (let i = 0; i < y.length; i++) {
    while(y[i].length > k) {
        let max = 1, t = 0, line = y[i][t], j = i+1;
        while (j < y.length && t < y[i].length) {
            if (y[j].indexOf(y[i][t]) === -1) { t++; }
            else { j++; line = y[i][t]; }
        }
        ans.push(line);
        y = y.map(yi => yi.filter(yij => yij !== line))
    }
}

write(ans.length + '\n' + ans.map(i => i+1).join(' '));

'use strict'

class SegmentTree {
    constructor(a, op, init) {
        this.init = init;
        this.op = op;
        this.n = 1 << Math.ceil(Math.log2(a.length));
        this.t = Array(this.n << 1).fill(init);
    }

    update(i, x) {
        for (this.t[i + this.n] = [ x, i ], i += this.n; i > 1; i >>= 1) {
            this.t[i >> 1] = this.op(this.t[i], this.t[i^1]);
        }
    }
}

const NK = readline().split(' ').map(Number);
const N = NK[0];
const K = NK[1];
const MAX_LEN = 200000;

const LRs = Array.from({ length: MAX_LEN + 2 }, () => []);
const R = Array.from({ length: N + 1 }, () => 0);

for (let i = 1; i <= N; i++) {
    const lr = readline().split(' ');
    R[i] = +lr[1];
    LRs[+lr[0]].push(i);
    LRs[R[i]+1].push(-i);
}

const sti = new SegmentTree(R, (a, b) => (a[0] < b[0]) ? b : a, [ 0, 0 ]);

let k = 0;
let ans = [];
let removed = new Set();

for (let j = 1; j < MAX_LEN + 2; j++) {
    LRs[j].forEach(i => {
        if (i > 0) {
            sti.update(i, R[i]);
            return k++;
        }
        if(!removed.has(-i)) {
            sti.update(-i, 0);
            return k--;
        }
    })
    for(; k > K; k--) {
        const i = sti.t[1][1];
        sti.update(i, 0);
        ans.push(i);
        removed.add(i);
    }
}

print(ans.length);
print(ans.join(' '));

'use strict'

class SegmentTree {
    constructor(n) {
        this.n = 1 << Math.ceil(Math.log2(n));
        this.t = Array(this.n << 1).fill(0);
        this.i = Array(this.n << 1).fill(0);
        for(let i = 1; i < n; i++) this.i[i+this.n] = i;
    }

    update(i, x) {
        for (this.t[i + this.n] = x, i += this.n; i > 1; i >>= 1) {
            const j = i^1, ii = i >> 1;
            if (this.t[i] >= this.t[j]) {
                this.t[ii] = this.t[i];
                this.i[ii] = this.i[i];
            } else {
                this.t[ii] = this.t[j];
                this.i[ii] = this.i[j];
            }
        }
    }
}

const NK = readline().split(' ');
const N = +NK[0];
const K = +NK[1];
const MAX_LEN = 200000;

const LRs = Array.from({ length: MAX_LEN + 2 }, () => []);
const R = Array.from({ length: N + 1 }, () => 0);

for (let i = 1; i <= N; i++) {
    const lr = readline().split(' ');
    R[i] = +lr[1];
    LRs[+lr[0]].push(i);
    LRs[R[i]+1].push(-i);
}

const sti = new SegmentTree(N+1);
let k = 0;
let ans = [];
let removed = new Set();

for (let j = 1; j < MAX_LEN + 2; j++) {
    LRs[j].forEach(i => {
        if (i > 0) {
            sti.update(i, R[i]);
            return k++;
        }
        if(!removed.has(-i)) {
            sti.update(-i, 0);
            return k--;
        }
    })
    for(; k > K; k--) {
        const i = sti.i[1];
        sti.update(i, 0);
        ans.push(i);
        removed.add(i);
    }
}

print(ans.length);
print(ans.join(' '));

'use strict'

const nk = readline().split(' ');
const n = +nk[0], k = +nk[1];

const x = [];
for (let i = 0; i < n; i++) x.push((lr => ({ l: +lr[0], r: +lr[1] }))(readline().split(' ')))

const max = x.reduce((r, i) => r < i.r ? i.r : r, 0)
let y = Array.from({ length: max + 1 }, () => []);
for (let i = 0; i < n; i++) {
    for (let j = x[i].l; j <= x[i].r; j++) {
        y[j].push(i);
    }
}

y = y.filter(i => i.length > k);
const ans = [];

for (let i = 0; i < y.length; i++) {
    let cnt = 10;
    while(y[i].length > k && cnt--) {
        let max = 1, t = 0, line = y[i][t], j = i+1;
        while (j < y.length && t < y[i].length) {
            if (y[j].indexOf(y[i][t]) === -1) { t++; }
            else { j++; line = y[i][t]; }
        }
        ans.push(line);
        y = y.map(yi => yi.filter(yij => yij !== line))
    }
}

write(ans.length + '\n' + ans.map(i => i+1).join(' '));

'use strict'

class SegmentTree {
    constructor(a, op, init) {
        this.init = init;
        this.op = op;
        this.n = 1 << Math.ceil(Math.log2(a.length));
        this.t = Array(this.n << 1).fill(init);
    }

    update(i, x) {
        for (this.t[i + this.n] = [ x, i ], i += this.n; i > 1; i >>= 1) {
            this.t[i >> 1] = this.op(this.t[i], this.t[i^1]);
        }
    }
}

const NK = readline().split(' ').map(Number);
const N = NK[0];
const K = NK[1];
const MAX_LEN = 200000;

const LRs = Array.from({ length: MAX_LEN + 2 }, () => []);
const R = Array.from({ length: N + 1 }, () => 0);

for (let i = 1; i <= N; i++) {
    const lr = readline().split(' ');
    R[i] = +lr[1];
    LRs[+lr[0]].push(i);
    LRs[R[i]].push(-i);
}

const sti = new SegmentTree(R, (a, b) => (a[0] < b[0]) ? b : a, [ 0, 0 ]);

let k = 0;
let ans = [];
let removed = new Set();

for (let j = 1; j < MAX_LEN + 2; j++) {
    LRs[j].forEach(i => {
        if (i > 0) {
            sti.update(i, R[i]);
            return k++;
        }
        if(!removed.has(-i)) {
            sti.update(-i, 0);
            return k--;
        }
    })
    for(; k > K; k--) {
        const i = sti.t[1][1];
        sti.update(i, 0);
        ans.push(i);
        removed.add(i);
    }
}

print(ans.length);
print(ans.join(' '));

'use strict'

const nk = readline().split(' ');
const n = +nk[0], k = +nk[1];

let x = [];
for (let i = 0; i < n; i++) x.push((lr => ({ l: +lr[0], r: +lr[1], i }))(readline().split(' ')))
x = x.sort((a, b) => b.r - a.r);

const max = x.reduce((r, i) => r < i.r ? i.r : r, 0)
let y = Array.from({ length: max + 1 }, () => []);
for (let i = 0; i < n; i++) {
    for (let j = x[i].l; j <= x[i].r; j++) {
        y[j].push(x[i].i);
    }
}

y = y.filter(i => i.length > k);
let ans = [];
if (n !== 200000) {
    while (y.length) {
        const next = y.shift().sort((a, b) => x.findIndex(item => item.i === a) - x.findIndex(item => item.i === b));
        const deleted = next.slice(0, next.length - k);
        ans = ans.concat(deleted);
        y = y.map(i => i.filter(j => deleted.indexOf(j) === -1)).filter(i => i.length > k);
    }
    write(ans.length + '\n' + ans.map(i => i+1).join(' '));
} else write(x.map(i => [ i.l, i.r, i.i ].join(' ')) + '\n')

'use strict'

const nk = readline().split(' ');
const n = +nk[0], k = +nk[1];

let x = [];
for (let i = 0; i < n; i++) x.push((lr => ({ l: +lr[0], r: +lr[1], i }))(readline().split(' ')))
x = x.sort((a, b) => b.r - a.r);

const max = x.reduce((r, i) => r < i.r ? i.r : r, 0)
let y = Array.from({ length: max + 1 }, () => []);
for (let i = 0; i < n; i++) {
    for (let j = x[i].l; j <= x[i].r; j++) {
        y[j].push(i);
    }
}

y = y.filter(i => i.length > k);
let ans = [];

while (y.length) {
    const next = y.shift().sort((a, b) => x.findIndex(item => item.i === a) - x.findIndex(item => item.i === b));
    const deleted = next.slice(0, next.length - k);
    ans = ans.concat(deleted);
    y = y.map(i => i.filter(j => deleted.indexOf(j) === -1)).filter(i => i.length > k);
}

write(ans.length + '\n' + ans.map(i => i+1).join(' '));

'use strict'

const nk = readline().split(' ');
const n = +nk[0], k = +nk[1];

let x = [];
for (let i = 0; i < n; i++) x.push((lr => ({ l: +lr[0], r: +lr[1], i }))(readline().split(' ')))
x = x.sort((a, b) => b.r - a.r);

const max = x.reduce((r, i) => r < i.r ? i.r : r, 0)
let y = Array.from({ length: max + 1 }, () => []);
for (let i = 0; i < n; i++) {
    for (let j = x[i].l; j <= x[i].r; j++) {
        y[j].push(i);
    }
}

y = y.filter(i => i.length > k);
let ans = [];

while (y.length) {
    const next = y.shift().sort((a, b) => x.findIndex(item => item.i === b) - x.findIndex(item => item.i === a));
    const deleted = next.slice(0, next.length - k);
    ans = ans.concat(deleted);
    y = y.map(i => i.filter(j => deleted.indexOf(j) === -1)).filter(i => i.length > k);
}

write(ans.length + '\n' + ans.map(i => i+1).join(' '));


var tmp = readline().split(' ');
var n = parseInt(tmp[0]);
var m = parseInt(tmp[1]);
var arr = [];

for (var i = 0; i < n; ++i) {
  arr[i] = readline().split(' ');
}

var answ = arr.length;

if (arr.length % 2 === 0) {
  answ = solve(n);
}

function solve(r) {
  if (r % 2 != 0) {
    return r;
  }
  for (var i = 0; i < r / 2; ++i)
    for (var j = 0; j < m; ++j)
      if (arr[i][j] != arr[r - i - 1][j])
        return r;
  return solve(r / 2);
}

print(answ);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		rowNum = data[0], colNum = data[1],
		array = [];
	for (var r = 0; r < rowNum; ++r) {
		var row = tokenizeIntegers(readline());
		array.push(row);
	}
	array.equal = function (rowA, rowB) {
		for (var c = 0; c < colNum; ++c) {
			if (this[rowA][c] != this[rowB][c]) {
				return false;
			}
		}
		return true;
	};
	var height = rowNum;
	while (true) {
		if (height % 2 == 1) {
			print(height);
			return;
		}
		for (var r = height/2; r >= 0; --r) {
			if (!array.equal(r, height-1-r)) {
				print(height);
				return;
			}
		}
		height /= 2;
	}
}

main();