def euclid(a,b):
while a!=b:
if a > b:
a = a - b
else:
b = b - a
return a
a = int(raw_input())
b = int(raw_input())
print euclid(a,b)
ZGVmIGV1Y2xpZChhLGIpOgoJCgl3aGlsZSBhIT1iOgoJICBpZiBhID4gYjoKCSAgCSBhID0gYSAtIGIKCSAgZWxzZToKCSAgCSBiID0gYiAtIGEKCXJldHVybiBhCgphID0gaW50KHJhd19pbnB1dCgpKQpiID0gaW50KHJhd19pbnB1dCgpKQoKcHJpbnQgZXVjbGlkKGEsYikJ