
def gcd(a, b)
  if a > b then
    a, b = b, a
  end
  
  while a % b != 0 do
    r = a % b
    a = b
    b = r
  end
  b
end

def main()
  a, b = gets.split.map{|x| x.to_i}
  puts gcd(a, b)
end

main

