def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


def main():
    a, b = map(int, input().split())
    b_divide = divisor(b)
    if a in b_divide:
        ans = a + b
    else:
        ans = b - a
    print(ans)


if __name__ == "__main__":
    main() def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table divisor i = 1 i 1 table = [] table [] while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
     i * i <= n i * i i i n if n % i == 0:
            table.append(i)
            table.append(n//i)
         n % i == 0 n % i n i 0 table.append(i) table.append table append i table.append(n//i) table.append table append n//i n i i += 1 i 1 table = list(set(table)) table list(set(table)) list set(table) set table return table table n n def main():
    a, b = map(int, input().split())
    b_divide = divisor(b)
    if a in b_divide:
        ans = a + b
    else:
        ans = b - a
    print(ans) main a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b b_divide = divisor(b) b_divide divisor(b) divisor b if a in b_divide:
        ans = a + b
    else:
        ans = b - a
     a in b_divide a b_divide ans = a + b ans a + b a b ans = b - a ans b - a b a print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table divisor def main():
    a, b = map(int, input().split())
    b_divide = divisor(b)
    if a in b_divide:
        ans = a + b
    else:
        ans = b - a
    print(ans) def main():
    a, b = map(int, input().split())
    b_divide = divisor(b)
    if a in b_divide:
        ans = a + b
    else:
        ans = b - a
    print(ans) main
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


def main():
    a, b = map(int, input().split())
    b_divide = divisor(b)
    if a in b_divide:
        ans = a + b
    else:
        ans = b - a
    print(ans)


if __name__ == "__main__":
    main()
