#約数列挙
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list

def main():
    A,B = map(int, input().split())
    div_list = make_divisor_list(B)

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


if __name__ == '__main__' :
    main() def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list make_divisor_list if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list num < 1 num 1 return [] [] elif num == 1:
        return [1]
     num == 1 num 1 return [1] [1] 1 divisor_list = [] divisor_list [] divisor_list.append(1) divisor_list.append divisor_list append 1 for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
         i range(2, num // 2 + 1) range 2 num // 2 + 1 num // 2 num 2 1 if num % i == 0:
                divisor_list.append(i)
         num % i == 0 num % i num i 0 divisor_list.append(i) divisor_list.append divisor_list append i divisor_list.append(num) divisor_list.append divisor_list append num return divisor_list divisor_list num num def main():
    A,B = map(int, input().split())
    div_list = make_divisor_list(B)

    if A in div_list:
        print(A+B)
    else:
        print(B-A) main A,B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B div_list = make_divisor_list(B) div_list make_divisor_list(B) make_divisor_list B if A in div_list:
        print(A+B)
    else:
        print(B-A) A in div_list A div_list print(A+B) print A+B A B print(B-A) print B-A B A if __name__ == '__main__' :
    main() __name__ == '__main__' __name__ '__main__' main() main def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list make_divisor_list def main():
    A,B = map(int, input().split())
    div_list = make_divisor_list(B)

    if A in div_list:
        print(A+B)
    else:
        print(B-A) def main():
    A,B = map(int, input().split())
    div_list = make_divisor_list(B)

    if A in div_list:
        print(A+B)
    else:
        print(B-A) main
#約数列挙
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list

def main():
    A,B = map(int, input().split())
    div_list = make_divisor_list(B)

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


if __name__ == '__main__' :
    main()