a = gets.split(" ").map{|k|k.to_i}

if a[0] >= a[1]
    x = a[0]
    y = a[1]
else
    x = a[1]
    y = a[0]
end
left = Float::INFINITY
loop do
    left = x % y
    break if left == 0
    x = y
    y = left
end

puts y
