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

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

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

reader.on('close', () => {
 var info = lines[0].split(' ');
 var n = Number(info[0]);
 var k = Number(info[1]);
 var s = 0;
 var ans = [];

 while(true){
   s = Math.abs(n - k)
   if(ans.indexOf(s) !== -1){break;}
   ans.push(s);
   n = s;
 }
 console.log(ans);
 console.log(Math.min(...ans));
}); 