def divisors(x):
    '''公約数をリスト型で返す関数'''
    divisors = []
    divisor = 1
    while(divisor <= x / divisor):
        if x % divisor == 0:
            divisors.append(divisor)
            if divisor == int(x / divisor):
                pass
            else:
                divisors.append(int(x / divisor))
        else:
            pass
        divisor += 1
    return sorted(divisors)

A, B = map(int, input().split())

if A in divisors(B):
    print(A + B)
else:
    print(B - A) def divisors(x):
    '''公約数をリスト型で返す関数'''
    divisors = []
    divisor = 1
    while(divisor <= x / divisor):
        if x % divisor == 0:
            divisors.append(divisor)
            if divisor == int(x / divisor):
                pass
            else:
                divisors.append(int(x / divisor))
        else:
            pass
        divisor += 1
    return sorted(divisors) divisors '''公約数をリスト型で返す関数''' divisors = [] divisors [] divisor = 1 divisor 1 while(divisor <= x / divisor):
        if x % divisor == 0:
            divisors.append(divisor)
            if divisor == int(x / divisor):
                pass
            else:
                divisors.append(int(x / divisor))
        else:
            pass
        divisor += 1
     divisor <= x / divisor divisor x / divisor x divisor if x % divisor == 0:
            divisors.append(divisor)
            if divisor == int(x / divisor):
                pass
            else:
                divisors.append(int(x / divisor))
        else:
            pass
         x % divisor == 0 x % divisor x divisor 0 divisors.append(divisor) divisors.append divisors append divisor if divisor == int(x / divisor):
                pass
            else:
                divisors.append(int(x / divisor))
         divisor == int(x / divisor) divisor int(x / divisor) int x / divisor x divisor divisors.append(int(x / divisor)) divisors.append divisors append int(x / divisor) int x / divisor x divisor divisor += 1 divisor 1 return sorted(divisors) sorted(divisors) sorted divisors x x A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B if A in divisors(B):
    print(A + B)
else:
    print(B - A) A in divisors(B) A divisors(B) divisors B print(A + B) print A + B A B print(B - A) print B - A B A B = map(int, input().split()) map(int, input().split()) B def divisors(x):
    '''公約数をリスト型で返す関数'''
    divisors = []
    divisor = 1
    while(divisor <= x / divisor):
        if x % divisor == 0:
            divisors.append(divisor)
            if divisor == int(x / divisor):
                pass
            else:
                divisors.append(int(x / divisor))
        else:
            pass
        divisor += 1
    return sorted(divisors) def divisors(x):
    '''公約数をリスト型で返す関数'''
    divisors = []
    divisor = 1
    while(divisor <= x / divisor):
        if x % divisor == 0:
            divisors.append(divisor)
            if divisor == int(x / divisor):
                pass
            else:
                divisors.append(int(x / divisor))
        else:
            pass
        divisor += 1
    return sorted(divisors) divisors A, B = map(int, input().split()) map(int, input().split()) A
def divisors(x):
    '''公約数をリスト型で返す関数'''
    divisors = []
    divisor = 1
    while(divisor <= x / divisor):
        if x % divisor == 0:
            divisors.append(divisor)
            if divisor == int(x / divisor):
                pass
            else:
                divisors.append(int(x / divisor))
        else:
            pass
        divisor += 1
    return sorted(divisors)

A, B = map(int, input().split())

if A in divisors(B):
    print(A + B)
else:
    print(B - A)
