def gcd(a, b)
  if b == 0 then
    return a
  else
    gcd(b, a % b)
  end
end

### main ###
x, y = STDIN.gets.to_s.split(" ")

x = x.to_i
y = y.to_i

if x > y then
  result = gcd(x, y)
else
  result = gcd(y, x)
end

p result