A, B = map(int, input().split()) for x in range(1, 100001): if x % A == x % B: print(x) break