import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a,b = map(int, input().split())
def sub(a):
    # 0^1^...^a-1
    ans = 0
    for i in range(a.bit_length()):
        l = pow(2,i)
        num = (a//(l*2)) * l + min(l, a%(l*2))
        num1 = a - num
        if num1%2:
            ans += l
    return ans
def sub2(a):
    ans = 0
    for i in range(a):
        ans ^= i
    return ans
ans = sub(b+1) ^ sub(a)
print(ans) import sys sys input = lambda : sys.stdin.readline().rstrip() input lambda : sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip sys.setrecursionlimit(max(1000, 10**9)) sys.setrecursionlimit sys setrecursionlimit max(1000, 10**9) max 1000 10**9 10 9 write = lambda x: sys.stdout.write(x+"\n") write lambda x: sys.stdout.write(x+"\n") sys.stdout.write(x+"\n") sys.stdout.write sys.stdout sys stdout write x+"\n" x "\n" x a,b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b def sub(a):
    # 0^1^...^a-1
    ans = 0
    for i in range(a.bit_length()):
        l = pow(2,i)
        num = (a//(l*2)) * l + min(l, a%(l*2))
        num1 = a - num
        if num1%2:
            ans += l
    return ans sub ans = 0 ans 0 for i in range(a.bit_length()):
        l = pow(2,i)
        num = (a//(l*2)) * l + min(l, a%(l*2))
        num1 = a - num
        if num1%2:
            ans += l
     i range(a.bit_length()) range a.bit_length() a.bit_length a bit_length l = pow(2,i) l pow(2,i) pow 2 i num = (a//(l*2)) * l + min(l, a%(l*2)) num (a//(l*2)) * l + min(l, a%(l*2)) (a//(l*2)) * l a//(l*2) a l*2 l 2 l min(l, a%(l*2)) min l a%(l*2) a l*2 l 2 num1 = a - num num1 a - num a num if num1%2:
            ans += l
     num1%2 num1 2 ans += l ans l return ans ans a a def sub2(a):
    ans = 0
    for i in range(a):
        ans ^= i
    return ans sub2 ans = 0 ans 0 for i in range(a):
        ans ^= i
     i range(a) range a ans ^= i ans i return ans ans a a ans = sub(b+1) ^ sub(a) ans sub(b+1) ^ sub(a) sub(b+1) sub b+1 b 1 sub(a) sub a print(ans) print ans a,b = map(int, input().split()) map(int, input().split()) a def sub2(a):
    ans = 0
    for i in range(a):
        ans ^= i
    return ans def sub2(a):
    ans = 0
    for i in range(a):
        ans ^= i
    return ans sub2 input = lambda : sys.stdin.readline().rstrip() lambda : sys.stdin.readline().rstrip() input ans = sub(b+1) ^ sub(a) sub(b+1) ^ sub(a) ans write = lambda x: sys.stdout.write(x+"\n") lambda x: sys.stdout.write(x+"\n") write b = map(int, input().split()) map(int, input().split()) b def sub(a):
    # 0^1^...^a-1
    ans = 0
    for i in range(a.bit_length()):
        l = pow(2,i)
        num = (a//(l*2)) * l + min(l, a%(l*2))
        num1 = a - num
        if num1%2:
            ans += l
    return ans def sub(a):
    # 0^1^...^a-1
    ans = 0
    for i in range(a.bit_length()):
        l = pow(2,i)
        num = (a//(l*2)) * l + min(l, a%(l*2))
        num1 = a - num
        if num1%2:
            ans += l
    return ans sub
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a,b = map(int, input().split())
def sub(a):
    # 0^1^...^a-1
    ans = 0
    for i in range(a.bit_length()):
        l = pow(2,i)
        num = (a//(l*2)) * l + min(l, a%(l*2))
        num1 = a - num
        if num1%2:
            ans += l
    return ans
def sub2(a):
    ans = 0
    for i in range(a):
        ans ^= i
    return ans
ans = sub(b+1) ^ sub(a)
print(ans)