A,B = map(int, input().split()) for i in range(1, 1000000): a = i % A b = B % i if a == b: print(i) break