def euclid(a,b):
while(b):
r = a % b
a = b
b = r
return a
a = int(raw_input())
b = int(raw_input())
print euclid(a,b)
ZGVmIGV1Y2xpZChhLGIpOgoKICAgIHdoaWxlKGIpOgogICAgCQoJCXIgPSBhICUgYgoJCWEgPSBiCgkJYiA9IHIKCQkKICAgIHJldHVybiBhCgphID0gaW50KHJhd19pbnB1dCgpKSAgICAKYiA9IGludChyYXdfaW5wdXQoKSkKCnByaW50IGV1Y2xpZChhLGIpCg==