let num = require('fs').readFileSync('/dev/stdin', 'UTF-8');

let numSplit = num.split(" ");
let num1 = numSplit[0] - 0;
let num2 = numSplit[1] - 0;

let biggerNum = Math.max(num1, num2);
let smallerNum = Math.min(num1, num2);

console.log(gcd(biggerNum, smallerNum));

function gcd(a, b) {
  if (b === 0) {
    return a;
  }
  return gcd(b, a % b);
}


