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

x_divisors = Array.new
y_divisors = Array.new

for i in 1..x do
   if x % i == 0
      x_divisors.push i
   end
end

for i in 1..y do
   if y % i == 0
      y_divisors.push i
   end
end

common_divisors = x_divisors & y_divisors
puts common_divisors[common_divisors.count-1]