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

# 0〜a - 1と0〜bの排他的論理和を考えればいい
# 排他的論理和は4つセットで消える（ぷよぷよのようだ）
def solve(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2)
    else:
        return 0

print(solve(a - 1) ^ solve(b)) a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b def solve(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2)
    else:
        return 0 solve if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2)
    else:
        return 0 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 return 0 0 x x print(solve(a - 1) ^ solve(b)) print solve(a - 1) ^ solve(b) solve(a - 1) solve a - 1 a 1 solve(b) solve b a, b = map(int, input().split()) map(int, input().split()) a b = map(int, input().split()) map(int, input().split()) b def solve(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2)
    else:
        return 0 def solve(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2)
    else:
        return 0 solve
a, b = map(int, input().split())

# 0〜a - 1と0〜bの排他的論理和を考えればいい
# 排他的論理和は4つセットで消える（ぷよぷよのようだ）
def solve(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2)
    else:
        return 0

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