A, B = sorted(map(int, input().split()), reverse=True) while B > 0: A, B = B, A%B print(A)