import sys

def S(): return sys.stdin.readline().rstrip()

A,B = map(int,S().split())

def f(n):  # 0からnまでのxor
    res = 0
    for i in range(41):  # 2**iの位
        if i == 0:
            res += ((n+1)//2) % 2
        else:
            a = n - ((n >> (i+1)) << (i+1))
            if a < 2**i or a % 2 == 1:
                continue
            else:
                res += 1 << i
    return res

print(f(B) ^ f(A-1)) import sys sys def S(): return sys.stdin.readline().rstrip() S A,B = map(int,S().split()) A map(int,S().split()) map int S().split() ().split () S split B def f(n):  # 0からnまでのxor
    res = 0
    for i in range(41):  # 2**iの位
        if i == 0:
            res += ((n+1)//2) % 2
        else:
            a = n - ((n >> (i+1)) << (i+1))
            if a < 2**i or a % 2 == 1:
                continue
            else:
                res += 1 << i
    return res f res = 0 res 0 for i in range(41):  # 2**iの位
        if i == 0:
            res += ((n+1)//2) % 2
        else:
            a = n - ((n >> (i+1)) << (i+1))
            if a < 2**i or a % 2 == 1:
                continue
            else:
                res += 1 << i
     i range(41) range 41 if i == 0:
            res += ((n+1)//2) % 2
        else:
            a = n - ((n >> (i+1)) << (i+1))
            if a < 2**i or a % 2 == 1:
                continue
            else:
                res += 1 << i
     i == 0 i 0 res += ((n+1)//2) % 2 res ((n+1)//2) % 2 (n+1)//2 n+1 n 1 2 2 a = n - ((n >> (i+1)) << (i+1)) a n - ((n >> (i+1)) << (i+1)) n (n >> (i+1)) << (i+1) n >> (i+1) n i+1 i 1 i+1 i 1 if a < 2**i or a % 2 == 1:
                continue
            else:
                res += 1 << i
     a < 2**i or a % 2 == 1 a < 2**i a 2**i 2 i a % 2 == 1 a % 2 a 2 1 continue res += 1 << i res 1 << i 1 i return res res n n print(f(B) ^ f(A-1)) print f(B) ^ f(A-1) f(B) f B f(A-1) f A-1 A 1 def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S def f(n):  # 0からnまでのxor
    res = 0
    for i in range(41):  # 2**iの位
        if i == 0:
            res += ((n+1)//2) % 2
        else:
            a = n - ((n >> (i+1)) << (i+1))
            if a < 2**i or a % 2 == 1:
                continue
            else:
                res += 1 << i
    return res def f(n):  # 0からnまでのxor
    res = 0
    for i in range(41):  # 2**iの位
        if i == 0:
            res += ((n+1)//2) % 2
        else:
            a = n - ((n >> (i+1)) << (i+1))
            if a < 2**i or a % 2 == 1:
                continue
            else:
                res += 1 << i
    return res f A,B = map(int,S().split()) map(int,S().split()) A B = map(int,S().split()) map(int,S().split()) B
import sys

def S(): return sys.stdin.readline().rstrip()

A,B = map(int,S().split())

def f(n):  # 0からnまでのxor
    res = 0
    for i in range(41):  # 2**iの位
        if i == 0:
            res += ((n+1)//2) % 2
        else:
            a = n - ((n >> (i+1)) << (i+1))
            if a < 2**i or a % 2 == 1:
                continue
            else:
                res += 1 << i
    return res

print(f(B) ^ f(A-1))