function main(input){
  let lines = input.split("\n");
  let x = lines[0].split(" ")[0];
  let y = lines[0].split(" ")[1];
  
  if (x < y){
        [x, y] = [y, x]
  }
  while (y > 0){
    r = x % y
    x = y
    y = r
  }
  console.log(x)
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
