var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split(' ').map(Number);

function gcd(x, y) {
  if (y === 0) {
    console.log(x);
  } else {
    gcd(y, x % y);
  }
}

gcd(input[0], input[1]);