def divisor(n)
  res = []
  (1..Math.sqrt(n)).each do |i|
    if (n % i).zero?
      res << i
      res << n/i
    end
  end
  res.sort
end

def gcd(x, y)
  (divisor(x) & divisor(y)).max
end

x, y = gets.split.map(&:to_i)
puts gcd(x, y)
