# ?????§??¬?´???°????±???????a??¨b?????\?????????
x, y = gets.split(" ").map(&:to_i)

# ?????§??¬?´???°????±???????
while x >= y && y != 0
    #?????????????±???????
    r = x % y
    x = y
    y = r
end
# ?????§??¬?´???°?????¨????????????
print x, "\n"