import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


A, B = list(map(int, input().split()))


# def f(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 f(n):
    if (n % 4 == 0):
        return n
    elif (n % 4 == 1):
        return (n ^ (n-1))
    elif (n % 4 == 2):
        return (n ^ (n-1) ^ (n-2))
    else:
        return 0


print(f(A-1) ^ f(B)) import numpy as np numpy from collections import deque from collections import defaultdict import heapq heapq import collections collections import itertools itertools import bisect bisect A, B = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split B def f(n):
    if (n % 4 == 0):
        return n
    elif (n % 4 == 1):
        return (n ^ (n-1))
    elif (n % 4 == 2):
        return (n ^ (n-1) ^ (n-2))
    else:
        return 0 f if (n % 4 == 0):
        return n
    elif (n % 4 == 1):
        return (n ^ (n-1))
    elif (n % 4 == 2):
        return (n ^ (n-1) ^ (n-2))
    else:
        return 0 n % 4 == 0 n % 4 n 4 0 return n n elif (n % 4 == 1):
        return (n ^ (n-1))
     n % 4 == 1 n % 4 n 4 1 return (n ^ (n-1)) n ^ (n-1) n n-1 n 1 elif (n % 4 == 2):
        return (n ^ (n-1) ^ (n-2))
     n % 4 == 2 n % 4 n 4 2 return (n ^ (n-1) ^ (n-2)) n ^ (n-1) ^ (n-2) n ^ (n-1) n n-1 n 1 n-2 n 2 return 0 0 n n print(f(A-1) ^ f(B)) print f(A-1) ^ f(B) f(A-1) f A-1 A 1 f(B) f B A, B = list(map(int, input().split())) list(map(int, input().split())) A B = list(map(int, input().split())) list(map(int, input().split())) B def f(n):
    if (n % 4 == 0):
        return n
    elif (n % 4 == 1):
        return (n ^ (n-1))
    elif (n % 4 == 2):
        return (n ^ (n-1) ^ (n-2))
    else:
        return 0 def f(n):
    if (n % 4 == 0):
        return n
    elif (n % 4 == 1):
        return (n ^ (n-1))
    elif (n % 4 == 2):
        return (n ^ (n-1) ^ (n-2))
    else:
        return 0 f
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


A, B = list(map(int, input().split()))


# def f(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 f(n):
    if (n % 4 == 0):
        return n
    elif (n % 4 == 1):
        return (n ^ (n-1))
    elif (n % 4 == 2):
        return (n ^ (n-1) ^ (n-2))
    else:
        return 0


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