class String
  def to_ia
    self.split(/\s+/).map {|s| s.to_i}
  end
end

def gcd(xy)
  xy.sort!
  x = xy[0]
  y = xy[1]
  r = y % x
  if r > 0
    gcd([x, y % x].sort)
  else
    x
  end
end

puts gcd(STDIN.readline.to_ia)