A,B = map(int, input().split())
b = []
for i in range(1,21):
    if B % i == 0:
        b.append(i)
if A in b:
    print(A+B)
else:
    print(B-A) A,B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B b = [] b [] for i in range(1,21):
    if B % i == 0:
        b.append(i) i range(1,21) range 1 21 if B % i == 0:
        b.append(i) B % i == 0 B % i B i 0 b.append(i) b.append b append i if A in b:
    print(A+B)
else:
    print(B-A) A in b A b print(A+B) print A+B A B print(B-A) print B-A B A b = [] [] b A,B = map(int, input().split()) map(int, input().split()) A B = map(int, input().split()) map(int, input().split()) B
A,B = map(int, input().split())
b = []
for i in range(1,21):
    if B % i == 0:
        b.append(i)
if A in b:
    print(A+B)
else:
    print(B-A)