def yakusu(n):
    a = []
    for i in range(1, int(n*0.5)+1):
        if n % i == 0:
            a.append(i)
    a.append(n)
    return a

A, B = map(int, input().split())
b = yakusu(B)
if A in b:
    print(A + B)
else:
    print(B - A) def yakusu(n):
    a = []
    for i in range(1, int(n*0.5)+1):
        if n % i == 0:
            a.append(i)
    a.append(n)
    return a yakusu a = [] a [] for i in range(1, int(n*0.5)+1):
        if n % i == 0:
            a.append(i)
     i range(1, int(n*0.5)+1) range 1 int(n*0.5)+1 int(n*0.5) int n*0.5 n 0.5 1 if n % i == 0:
            a.append(i)
     n % i == 0 n % i n i 0 a.append(i) a.append a append i a.append(n) a.append a append n return a a n n A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B b = yakusu(B) b yakusu(B) yakusu B 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 A, B = map(int, input().split()) map(int, input().split()) A def yakusu(n):
    a = []
    for i in range(1, int(n*0.5)+1):
        if n % i == 0:
            a.append(i)
    a.append(n)
    return a def yakusu(n):
    a = []
    for i in range(1, int(n*0.5)+1):
        if n % i == 0:
            a.append(i)
    a.append(n)
    return a yakusu B = map(int, input().split()) map(int, input().split()) B b = yakusu(B) yakusu(B) b
def yakusu(n):
    a = []
    for i in range(1, int(n*0.5)+1):
        if n % i == 0:
            a.append(i)
    a.append(n)
    return a

A, B = map(int, input().split())
b = yakusu(B)
if A in b:
    print(A + B)
else:
    print(B - A)