#37461: python解(參考歐幾里得算法


a0911566208@gmail.com (Verbal)


thew = input().split()
a = int(thew[0])
b = int(thew[1])
r = b
while r > 0:
    b = r
    r = a%b
    a = b
print(b)