def GCD(m, n): while True: k = m % n m = n n = k if k == 0: break return m A = int(input()) B = int(input()) print(GCD(A + B, A * B))