def F(X):
    if X % 4 == 1:
        return 1
    if X % 4 == 2:
        return X + 1
    if X % 4 == 3:
        return 0
    if X % 4 == 0:
        return X


def test():
    x = 0
    for i in range(1, 50):
        x ^= i
        print(i, ":", x)


if __name__ == "__main__":
    A, B = map(int, input().split())
    if A == 0:
        print(F(B))
    else:
        print(F(B) ^ F(A-1)) def F(X):
    if X % 4 == 1:
        return 1
    if X % 4 == 2:
        return X + 1
    if X % 4 == 3:
        return 0
    if X % 4 == 0:
        return X F if X % 4 == 1:
        return 1
     X % 4 == 1 X % 4 X 4 1 return 1 1 if X % 4 == 2:
        return X + 1
     X % 4 == 2 X % 4 X 4 2 return X + 1 X + 1 X 1 if X % 4 == 3:
        return 0
     X % 4 == 3 X % 4 X 4 3 return 0 0 if X % 4 == 0:
        return X X % 4 == 0 X % 4 X 4 0 return X X X X def test():
    x = 0
    for i in range(1, 50):
        x ^= i
        print(i, ":", x) test x = 0 x 0 for i in range(1, 50):
        x ^= i
        print(i, ":", x) i range(1, 50) range 1 50 x ^= i x i print(i, ":", x) print i ":" x if __name__ == "__main__":
    A, B = map(int, input().split())
    if A == 0:
        print(F(B))
    else:
        print(F(B) ^ F(A-1)) __name__ == "__main__" __name__ "__main__" A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B if A == 0:
        print(F(B))
    else:
        print(F(B) ^ F(A-1)) A == 0 A 0 print(F(B)) print F(B) F B 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 F(X):
    if X % 4 == 1:
        return 1
    if X % 4 == 2:
        return X + 1
    if X % 4 == 3:
        return 0
    if X % 4 == 0:
        return X def F(X):
    if X % 4 == 1:
        return 1
    if X % 4 == 2:
        return X + 1
    if X % 4 == 3:
        return 0
    if X % 4 == 0:
        return X F A, B = map(int, input().split()) map(int, input().split()) A def test():
    x = 0
    for i in range(1, 50):
        x ^= i
        print(i, ":", x) def test():
    x = 0
    for i in range(1, 50):
        x ^= i
        print(i, ":", x) test B = map(int, input().split()) map(int, input().split()) B
def F(X):
    if X % 4 == 1:
        return 1
    if X % 4 == 2:
        return X + 1
    if X % 4 == 3:
        return 0
    if X % 4 == 0:
        return X


def test():
    x = 0
    for i in range(1, 50):
        x ^= i
        print(i, ":", x)


if __name__ == "__main__":
    A, B = map(int, input().split())
    if A == 0:
        print(F(B))
    else:
        print(F(B) ^ F(A-1))