#!/usr/bin/env python3
import sys


def f(B, d):
    '''
    >>> f(6, 0) # 1, 3, 5
    3
    >>> f(6, 1) # 2, 3, 6
    3
    >>> f(6, 2) # 4, 5, 6
    3
    >>> f(6, 3)
    0
    '''
    r = 2**(d+1)
    rr = 2 ** d
    return B // r * rr + max(B % r - rr + 1, 0)
    
def g(A, B, d):
    '''
    >>> g(0, 6, 0) # 1, 3, 5
    3
    >>> g(0, 6, 1) # 2, 3, 6
    3
    >>> g(0, 6, 2) # 4, 5, 6
    3
    >>> g(2, 6, 0) # 3, 5
    2
    '''
    if A == 0:
        return f(B, d)
    return f(B, d) - f(A-1, d)

def solve(A: int, B: int):
    ans = 0
    for d in range(10000, -1, -1):
        ans <<= 1
        ans += g(A, B, d) % 2
    return ans


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(A, B))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    test()
    main() import sys sys def f(B, d):
    '''
    >>> f(6, 0) # 1, 3, 5
    3
    >>> f(6, 1) # 2, 3, 6
    3
    >>> f(6, 2) # 4, 5, 6
    3
    >>> f(6, 3)
    0
    '''
    r = 2**(d+1)
    rr = 2 ** d
    return B // r * rr + max(B % r - rr + 1, 0)
     f '''
    >>> f(6, 0) # 1, 3, 5
    3
    >>> f(6, 1) # 2, 3, 6
    3
    >>> f(6, 2) # 4, 5, 6
    3
    >>> f(6, 3)
    0
    ''' r = 2**(d+1) r 2**(d+1) 2 d+1 d 1 rr = 2 ** d rr 2 ** d 2 d return B // r * rr + max(B % r - rr + 1, 0) B // r * rr + max(B % r - rr + 1, 0) B // r * rr B // r B r rr max(B % r - rr + 1, 0) max B % r - rr + 1 B % r - rr B % r B r rr 1 0 B B d d def g(A, B, d):
    '''
    >>> g(0, 6, 0) # 1, 3, 5
    3
    >>> g(0, 6, 1) # 2, 3, 6
    3
    >>> g(0, 6, 2) # 4, 5, 6
    3
    >>> g(2, 6, 0) # 3, 5
    2
    '''
    if A == 0:
        return f(B, d)
    return f(B, d) - f(A-1, d) g '''
    >>> g(0, 6, 0) # 1, 3, 5
    3
    >>> g(0, 6, 1) # 2, 3, 6
    3
    >>> g(0, 6, 2) # 4, 5, 6
    3
    >>> g(2, 6, 0) # 3, 5
    2
    ''' if A == 0:
        return f(B, d)
     A == 0 A 0 return f(B, d) f(B, d) f B d return f(B, d) - f(A-1, d) f(B, d) - f(A-1, d) f(B, d) f B d f(A-1, d) f A-1 A 1 d A A B B d d def solve(A: int, B: int):
    ans = 0
    for d in range(10000, -1, -1):
        ans <<= 1
        ans += g(A, B, d) % 2
    return ans


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools solve ans = 0 ans 0 for d in range(10000, -1, -1):
        ans <<= 1
        ans += g(A, B, d) % 2
     d range(10000, -1, -1) range 10000 -1 -1 ans <<= 1 ans 1 ans += g(A, B, d) % 2 ans g(A, B, d) % 2 g(A, B, d) g A B d 2 return ans ans A: int A B: int B def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(A, B)) main def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
     iterate_tokens for line in sys.stdin:
            for word in line.split():
                yield word
     line sys.stdin sys stdin for word in line.split():
                yield word
     word line.split() line.split line split yield word word tokens = iterate_tokens() tokens iterate_tokens() iterate_tokens A = int(next(tokens)) A int(next(tokens)) int next(tokens) next tokens B = int(next(tokens)) B int(next(tokens)) int next(tokens) next tokens print(solve(A, B)) print solve(A, B) solve A B def test():
    import doctest
    doctest.testmod() test import doctest doctest doctest.testmod() doctest.testmod doctest testmod if __name__ == '__main__':
    test()
    main() __name__ == '__main__' __name__ '__main__' test() test main() main def solve(A: int, B: int):
    ans = 0
    for d in range(10000, -1, -1):
        ans <<= 1
        ans += g(A, B, d) % 2
    return ans


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools def solve(A: int, B: int):
    ans = 0
    for d in range(10000, -1, -1):
        ans <<= 1
        ans += g(A, B, d) % 2
    return ans


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools solve def g(A, B, d):
    '''
    >>> g(0, 6, 0) # 1, 3, 5
    3
    >>> g(0, 6, 1) # 2, 3, 6
    3
    >>> g(0, 6, 2) # 4, 5, 6
    3
    >>> g(2, 6, 0) # 3, 5
    2
    '''
    if A == 0:
        return f(B, d)
    return f(B, d) - f(A-1, d) def g(A, B, d):
    '''
    >>> g(0, 6, 0) # 1, 3, 5
    3
    >>> g(0, 6, 1) # 2, 3, 6
    3
    >>> g(0, 6, 2) # 4, 5, 6
    3
    >>> g(2, 6, 0) # 3, 5
    2
    '''
    if A == 0:
        return f(B, d)
    return f(B, d) - f(A-1, d) g def f(B, d):
    '''
    >>> f(6, 0) # 1, 3, 5
    3
    >>> f(6, 1) # 2, 3, 6
    3
    >>> f(6, 2) # 4, 5, 6
    3
    >>> f(6, 3)
    0
    '''
    r = 2**(d+1)
    rr = 2 ** d
    return B // r * rr + max(B % r - rr + 1, 0)
     def f(B, d):
    '''
    >>> f(6, 0) # 1, 3, 5
    3
    >>> f(6, 1) # 2, 3, 6
    3
    >>> f(6, 2) # 4, 5, 6
    3
    >>> f(6, 3)
    0
    '''
    r = 2**(d+1)
    rr = 2 ** d
    return B // r * rr + max(B % r - rr + 1, 0)
     f def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(A, B)) def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(A, B)) main def test():
    import doctest
    doctest.testmod() def test():
    import doctest
    doctest.testmod() test
#!/usr/bin/env python3
import sys


def f(B, d):
    '''
    >>> f(6, 0) # 1, 3, 5
    3
    >>> f(6, 1) # 2, 3, 6
    3
    >>> f(6, 2) # 4, 5, 6
    3
    >>> f(6, 3)
    0
    '''
    r = 2**(d+1)
    rr = 2 ** d
    return B // r * rr + max(B % r - rr + 1, 0)
    
def g(A, B, d):
    '''
    >>> g(0, 6, 0) # 1, 3, 5
    3
    >>> g(0, 6, 1) # 2, 3, 6
    3
    >>> g(0, 6, 2) # 4, 5, 6
    3
    >>> g(2, 6, 0) # 3, 5
    2
    '''
    if A == 0:
        return f(B, d)
    return f(B, d) - f(A-1, d)

def solve(A: int, B: int):
    ans = 0
    for d in range(10000, -1, -1):
        ans <<= 1
        ans += g(A, B, d) % 2
    return ans


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(A, B))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    test()
    main()
