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