data = list(map(int, input().split())) A = data[0] B = data[1] target = 0 while True: target += 1 comp_1 = target % A comp_2 = B % target if comp_1 == comp_2: break print(target)