A, B = map(int, input().split())
for i in range(B+1):
    if i == 0:
        continue
    if B % (A*i) == 0:
        print(A + B)
        exit()
print(B - A) A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B for i in range(B+1):
    if i == 0:
        continue
    if B % (A*i) == 0:
        print(A + B)
        exit() i range(B+1) range B+1 B 1 if i == 0:
        continue
     i == 0 i 0 continue if B % (A*i) == 0:
        print(A + B)
        exit() B % (A*i) == 0 B % (A*i) B A*i A i 0 print(A + B) print A + B A B exit() exit print(B - A) print B - A B A B = map(int, input().split()) map(int, input().split()) B A, B = map(int, input().split()) map(int, input().split()) A
A, B = map(int, input().split())
for i in range(B+1):
    if i == 0:
        continue
    if B % (A*i) == 0:
        print(A + B)
        exit()
print(B - A)