A, B = map(int, input().split()) if A < B: A, B = B, A while B > 0: r = A % B A = B B = r print(A)