input = ARGF.gets
x = input.split(" ")[0].to_i
y = input.split(" ")[1].to_i

answer = 0
1.upto(x) do |v|
  if x % v == 0
    if y % v == 0
      if answer < v
        answer = v
      end
    end
  end
end

puts answer