import sys
input = sys.stdin.readline

def print_ans(A, B):
    """Test Case
    >>> print_ans(4, 12)
    16
    >>> print_ans(8, 20)
    12
    >>> print_ans(1, 1)
    2
    """
    if B % A == 0:
        print(A + B)
    else:
        print(B-A)

if __name__ == '__main__':
    A, B = map(int, input().rstrip().split())
    print_ans(A, B)

 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def print_ans(A, B):
    """Test Case
    >>> print_ans(4, 12)
    16
    >>> print_ans(8, 20)
    12
    >>> print_ans(1, 1)
    2
    """
    if B % A == 0:
        print(A + B)
    else:
        print(B-A) print_ans """Test Case
    >>> print_ans(4, 12)
    16
    >>> print_ans(8, 20)
    12
    >>> print_ans(1, 1)
    2
    """ if B % A == 0:
        print(A + B)
    else:
        print(B-A) B % A == 0 B % A B A 0 print(A + B) print A + B A B print(B-A) print B-A B A A A B B if __name__ == '__main__':
    A, B = map(int, input().rstrip().split())
    print_ans(A, B) __name__ == '__main__' __name__ '__main__' A, B = map(int, input().rstrip().split()) A map(int, input().rstrip().split()) map int input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split B print_ans(A, B) print_ans A B A, B = map(int, input().rstrip().split()) map(int, input().rstrip().split()) A input = sys.stdin.readline sys.stdin.readline input B = map(int, input().rstrip().split()) map(int, input().rstrip().split()) B def print_ans(A, B):
    """Test Case
    >>> print_ans(4, 12)
    16
    >>> print_ans(8, 20)
    12
    >>> print_ans(1, 1)
    2
    """
    if B % A == 0:
        print(A + B)
    else:
        print(B-A) def print_ans(A, B):
    """Test Case
    >>> print_ans(4, 12)
    16
    >>> print_ans(8, 20)
    12
    >>> print_ans(1, 1)
    2
    """
    if B % A == 0:
        print(A + B)
    else:
        print(B-A) print_ans
import sys
input = sys.stdin.readline

def print_ans(A, B):
    """Test Case
    >>> print_ans(4, 12)
    16
    >>> print_ans(8, 20)
    12
    >>> print_ans(1, 1)
    2
    """
    if B % A == 0:
        print(A + B)
    else:
        print(B-A)

if __name__ == '__main__':
    A, B = map(int, input().rstrip().split())
    print_ans(A, B)


