from sys import stdin
sp = stdin.readline().split()
A, B = int(sp[0]), int(sp[1])

def div(num):
    l = []
    for itr in range(1,num+1):
        if num % itr == 0:
            l.append(itr)
    return l

B_divisor = div(B)
if A in B_divisor:
    print(A+B)
else:
    print(B-A) from sys import stdin sp = stdin.readline().split() sp stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split A, B = int(sp[0]), int(sp[1]) A int(sp[0]) int sp[0] sp 0 B int(sp[1]) int sp[1] sp 1 def div(num):
    l = []
    for itr in range(1,num+1):
        if num % itr == 0:
            l.append(itr)
    return l div l = [] l [] for itr in range(1,num+1):
        if num % itr == 0:
            l.append(itr)
     itr range(1,num+1) range 1 num+1 num 1 if num % itr == 0:
            l.append(itr)
     num % itr == 0 num % itr num itr 0 l.append(itr) l.append l append itr return l l num num B_divisor = div(B) B_divisor div(B) div B if A in B_divisor:
    print(A+B)
else:
    print(B-A) A in B_divisor A B_divisor print(A+B) print A+B A B print(B-A) print B-A B A sp = stdin.readline().split() stdin.readline().split() sp def div(num):
    l = []
    for itr in range(1,num+1):
        if num % itr == 0:
            l.append(itr)
    return l def div(num):
    l = []
    for itr in range(1,num+1):
        if num % itr == 0:
            l.append(itr)
    return l div B = int(sp[0]), int(sp[1]) int(sp[1]) B B_divisor = div(B) div(B) B_divisor A, B = int(sp[0]), int(sp[1]) int(sp[0]) A
from sys import stdin
sp = stdin.readline().split()
A, B = int(sp[0]), int(sp[1])

def div(num):
    l = []
    for itr in range(1,num+1):
        if num % itr == 0:
            l.append(itr)
    return l

B_divisor = div(B)
if A in B_divisor:
    print(A+B)
else:
    print(B-A)