# 0123の周期でXORはリセットされるため剰余だけ考える
def solve(x):
    if x % 4 == 3:
        return 0
    elif x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2)


a, b = map(int, input().split())


print(solve(a - 1) ^ solve(b)) def solve(x):
    if x % 4 == 3:
        return 0
    elif x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2) solve if x % 4 == 3:
        return 0
    elif x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2) x % 4 == 3 x % 4 x 4 3 return 0 0 elif x % 4 == 0:
        return x
     x % 4 == 0 x % 4 x 4 0 return x x elif x % 4 == 1:
        return x ^ (x - 1)
     x % 4 == 1 x % 4 x 4 1 return x ^ (x - 1) x ^ (x - 1) x x - 1 x 1 elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2) x % 4 == 2 x % 4 x 4 2 return x ^ (x - 1) ^ (x - 2) x ^ (x - 1) ^ (x - 2) x ^ (x - 1) x x - 1 x 1 x - 2 x 2 x x a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b print(solve(a - 1) ^ solve(b)) print solve(a - 1) ^ solve(b) solve(a - 1) solve a - 1 a 1 solve(b) solve b def solve(x):
    if x % 4 == 3:
        return 0
    elif x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2) def solve(x):
    if x % 4 == 3:
        return 0
    elif x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2) solve a, b = map(int, input().split()) map(int, input().split()) a b = map(int, input().split()) map(int, input().split()) b
# 0123の周期でXORはリセットされるため剰余だけ考える
def solve(x):
    if x % 4 == 3:
        return 0
    elif x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2)


a, b = map(int, input().split())


print(solve(a - 1) ^ solve(b))