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

const lines = [];
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line)
});
reader.on('close', () => {
  const inputArray = lines[0].split(' ');
  const inputArrayNumber = inputArray.map( str => parseInt(str, 10));
  let result = inputArrayNumber[0]
  let changeNumber = inputArrayNumber[0]
  for (let i = 1; i < 10000; i++) {
    if(Math.abs(changeNumber - inputArrayNumber[1]) < result){
      result = Math.abs(changeNumber - inputArrayNumber[1])
    }
    changeNumber = Math.abs(changeNumber - inputArrayNumber[1])
  }
  console.log(result)
});