import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def g(x):
    if x <= 0:
        return 0
    tmp = x
    n = 0
    while tmp > 0:
        tmp //= 2
        n += 1
    l = [0]*n
    for i in range(n):
        if i==0:
            l[i] = 1 if x%4==1 or x%4==2 else 0
        else:
            l[i] = max(x%(1<<(i+1))-(1<<i)+1, 0)%2
    return sum(l[i]*(2**i) for i in range(n))


def main():
    A, B = mi()
    print(g(B)^g(A-1))

if __name__ == '__main__':
    main() import sys sys sys.setrecursionlimit(500000) sys.setrecursionlimit sys setrecursionlimit 500000 MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 def input():
    return sys.stdin.readline()[:-1] input return sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 def mi():
    return map(int, input().split()) mi return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def ii():
    return int(input()) ii return int(input()) int(input()) int input() input def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)] i2 list(mi()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) list(mi()) list mi() mi tmp = [list(mi()) for i in range(n)] tmp [list(mi()) for i in range(n)] list(i) for i in zip(*tmp) for i in zip(*tmp) i zip(*tmp) zip *tmp tmp for i in zip(*tmp) list(i) list i return [list(i) for i in zip(*tmp)] [list(i) for i in zip(*tmp)] n n def g(x):
    if x <= 0:
        return 0
    tmp = x
    n = 0
    while tmp > 0:
        tmp //= 2
        n += 1
    l = [0]*n
    for i in range(n):
        if i==0:
            l[i] = 1 if x%4==1 or x%4==2 else 0
        else:
            l[i] = max(x%(1<<(i+1))-(1<<i)+1, 0)%2
    return sum(l[i]*(2**i) for i in range(n)) g if x <= 0:
        return 0
     x <= 0 x 0 return 0 0 tmp = x tmp x n = 0 n 0 while tmp > 0:
        tmp //= 2
        n += 1
     tmp > 0 tmp 0 tmp //= 2 tmp 2 n += 1 n 1 l = [0]*n l [0]*n [0] 0 n for i in range(n):
        if i==0:
            l[i] = 1 if x%4==1 or x%4==2 else 0
        else:
            l[i] = max(x%(1<<(i+1))-(1<<i)+1, 0)%2
     i range(n) range n if i==0:
            l[i] = 1 if x%4==1 or x%4==2 else 0
        else:
            l[i] = max(x%(1<<(i+1))-(1<<i)+1, 0)%2
     i==0 i 0 l[i] = 1 if x%4==1 or x%4==2 else 0 l[i] l i 1 if x%4==1 or x%4==2 else 0 x%4==1 or x%4==2 x%4==1 x%4 x 4 1 x%4==2 x%4 x 4 2 1 0 l[i] = max(x%(1<<(i+1))-(1<<i)+1, 0)%2 l[i] l i max(x%(1<<(i+1))-(1<<i)+1, 0)%2 max(x%(1<<(i+1))-(1<<i)+1, 0) max x%(1<<(i+1))-(1<<i)+1 x%(1<<(i+1))-(1<<i) x%(1<<(i+1)) x 1<<(i+1) 1 i+1 i 1 1<<i 1 i 1 0 2 return sum(l[i]*(2**i) for i in range(n)) sum(l[i]*(2**i) for i in range(n)) sum l[i]*(2**i) l[i] l i 2**i 2 i x x def main():
    A, B = mi()
    print(g(B)^g(A-1)) main A, B = mi() A mi() mi B print(g(B)^g(A-1)) print g(B)^g(A-1) g(B) g B g(A-1) g A-1 A 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def mi():
    return map(int, input().split()) def mi():
    return map(int, input().split()) mi MOD = 10**9+7 10**9+7 MOD def ii():
    return int(input()) def ii():
    return int(input()) ii def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)] def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)] i2 def main():
    A, B = mi()
    print(g(B)^g(A-1)) def main():
    A, B = mi()
    print(g(B)^g(A-1)) main def input():
    return sys.stdin.readline()[:-1] def input():
    return sys.stdin.readline()[:-1] input def g(x):
    if x <= 0:
        return 0
    tmp = x
    n = 0
    while tmp > 0:
        tmp //= 2
        n += 1
    l = [0]*n
    for i in range(n):
        if i==0:
            l[i] = 1 if x%4==1 or x%4==2 else 0
        else:
            l[i] = max(x%(1<<(i+1))-(1<<i)+1, 0)%2
    return sum(l[i]*(2**i) for i in range(n)) def g(x):
    if x <= 0:
        return 0
    tmp = x
    n = 0
    while tmp > 0:
        tmp //= 2
        n += 1
    l = [0]*n
    for i in range(n):
        if i==0:
            l[i] = 1 if x%4==1 or x%4==2 else 0
        else:
            l[i] = max(x%(1<<(i+1))-(1<<i)+1, 0)%2
    return sum(l[i]*(2**i) for i in range(n)) g
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def g(x):
    if x <= 0:
        return 0
    tmp = x
    n = 0
    while tmp > 0:
        tmp //= 2
        n += 1
    l = [0]*n
    for i in range(n):
        if i==0:
            l[i] = 1 if x%4==1 or x%4==2 else 0
        else:
            l[i] = max(x%(1<<(i+1))-(1<<i)+1, 0)%2
    return sum(l[i]*(2**i) for i in range(n))


def main():
    A, B = mi()
    print(g(B)^g(A-1))

if __name__ == '__main__':
    main()
