

def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))

def g(X):
    """
    000
    001
    010
    011
    100
    101
    110
    111
    """
    p = 1
    i = 39
    digits = [0]*40
    N = X+1
    while i > -1:
        digits[i] = N//(2*p)*p
        if N%(2*p)-p > 0:
            digits[i] += N%(2*p)-p
        p *= 2
        i -= 1
    answer = 0
    p = 1
    for d in digits[::-1]:
        if d%2 == 1:
            answer += p
        p *= 2
    return answer


def solve():
    """
    f(A, B) = A^...^B
    g(A) = 0^...^A
    g(B) = 0^...^B

    f(A, B) = g(A-1)^g(B)
    f(0, B) = g(B)
    """
    A, B = read_ints()
    if A == 0:
        return g(B)
    return g(A-1)^g(B)


if __name__ == '__main__':
    print(solve()) def read_int():
    return int(input().strip()) read_int return int(input().strip()) int(input().strip()) int input().strip() ().strip () input strip def read_ints():
    return list(map(int, input().strip().split(' '))) read_ints return list(map(int, input().strip().split(' '))) list(map(int, input().strip().split(' '))) list map(int, input().strip().split(' ')) map int input().strip().split(' ') ().strip().split ().strip() ().strip () input strip split ' ' def g(X):
    """
    000
    001
    010
    011
    100
    101
    110
    111
    """
    p = 1
    i = 39
    digits = [0]*40
    N = X+1
    while i > -1:
        digits[i] = N//(2*p)*p
        if N%(2*p)-p > 0:
            digits[i] += N%(2*p)-p
        p *= 2
        i -= 1
    answer = 0
    p = 1
    for d in digits[::-1]:
        if d%2 == 1:
            answer += p
        p *= 2
    return answer g """
    000
    001
    010
    011
    100
    101
    110
    111
    """ p = 1 p 1 i = 39 i 39 digits = [0]*40 digits [0]*40 [0] 0 40 N = X+1 N X+1 X 1 while i > -1:
        digits[i] = N//(2*p)*p
        if N%(2*p)-p > 0:
            digits[i] += N%(2*p)-p
        p *= 2
        i -= 1
     i > -1 i -1 digits[i] = N//(2*p)*p digits[i] digits i N//(2*p)*p N//(2*p) N 2*p 2 p p if N%(2*p)-p > 0:
            digits[i] += N%(2*p)-p
         N%(2*p)-p > 0 N%(2*p)-p N%(2*p) N 2*p 2 p p 0 digits[i] += N%(2*p)-p digits[i] digits i N%(2*p)-p N%(2*p) N 2*p 2 p p p *= 2 p 2 i -= 1 i 1 answer = 0 answer 0 p = 1 p 1 for d in digits[::-1]:
        if d%2 == 1:
            answer += p
        p *= 2
     d digits[::-1] digits ::-1 -1 if d%2 == 1:
            answer += p
         d%2 == 1 d%2 d 2 1 answer += p answer p p *= 2 p 2 return answer answer X X def solve():
    """
    f(A, B) = A^...^B
    g(A) = 0^...^A
    g(B) = 0^...^B

    f(A, B) = g(A-1)^g(B)
    f(0, B) = g(B)
    """
    A, B = read_ints()
    if A == 0:
        return g(B)
    return g(A-1)^g(B) solve """
    f(A, B) = A^...^B
    g(A) = 0^...^A
    g(B) = 0^...^B

    f(A, B) = g(A-1)^g(B)
    f(0, B) = g(B)
    """ A, B = read_ints() A read_ints() read_ints B if A == 0:
        return g(B)
     A == 0 A 0 return g(B) g(B) g B return g(A-1)^g(B) g(A-1)^g(B) g(A-1) g A-1 A 1 g(B) g B if __name__ == '__main__':
    print(solve()) __name__ == '__main__' __name__ '__main__' print(solve()) print solve() solve def g(X):
    """
    000
    001
    010
    011
    100
    101
    110
    111
    """
    p = 1
    i = 39
    digits = [0]*40
    N = X+1
    while i > -1:
        digits[i] = N//(2*p)*p
        if N%(2*p)-p > 0:
            digits[i] += N%(2*p)-p
        p *= 2
        i -= 1
    answer = 0
    p = 1
    for d in digits[::-1]:
        if d%2 == 1:
            answer += p
        p *= 2
    return answer def g(X):
    """
    000
    001
    010
    011
    100
    101
    110
    111
    """
    p = 1
    i = 39
    digits = [0]*40
    N = X+1
    while i > -1:
        digits[i] = N//(2*p)*p
        if N%(2*p)-p > 0:
            digits[i] += N%(2*p)-p
        p *= 2
        i -= 1
    answer = 0
    p = 1
    for d in digits[::-1]:
        if d%2 == 1:
            answer += p
        p *= 2
    return answer g def read_ints():
    return list(map(int, input().strip().split(' '))) def read_ints():
    return list(map(int, input().strip().split(' '))) read_ints def solve():
    """
    f(A, B) = A^...^B
    g(A) = 0^...^A
    g(B) = 0^...^B

    f(A, B) = g(A-1)^g(B)
    f(0, B) = g(B)
    """
    A, B = read_ints()
    if A == 0:
        return g(B)
    return g(A-1)^g(B) def solve():
    """
    f(A, B) = A^...^B
    g(A) = 0^...^A
    g(B) = 0^...^B

    f(A, B) = g(A-1)^g(B)
    f(0, B) = g(B)
    """
    A, B = read_ints()
    if A == 0:
        return g(B)
    return g(A-1)^g(B) solve def read_int():
    return int(input().strip()) def read_int():
    return int(input().strip()) read_int


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))

def g(X):
    """
    000
    001
    010
    011
    100
    101
    110
    111
    """
    p = 1
    i = 39
    digits = [0]*40
    N = X+1
    while i > -1:
        digits[i] = N//(2*p)*p
        if N%(2*p)-p > 0:
            digits[i] += N%(2*p)-p
        p *= 2
        i -= 1
    answer = 0
    p = 1
    for d in digits[::-1]:
        if d%2 == 1:
            answer += p
        p *= 2
    return answer


def solve():
    """
    f(A, B) = A^...^B
    g(A) = 0^...^A
    g(B) = 0^...^B

    f(A, B) = g(A-1)^g(B)
    f(0, B) = g(B)
    """
    A, B = read_ints()
    if A == 0:
        return g(B)
    return g(A-1)^g(B)


if __name__ == '__main__':
    print(solve())
