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

def cumxor(P):
  x = P % 4
  if x == 0:
    return P
  elif x == 1:
    return 1
  elif x == 2:
    return P+1
  else:
    return 0

if A == B:
  print(A)
elif A == 0:
  print(cumxor(B))
else:
  print(cumxor(A-1) ^ cumxor(B))

# 試した
#def cumxor(P):
#  ret = 0
#  for i in range(0,P+1):
#    ret = ret ^ i
#  return ret 
#for i in range(0,130):
#  cx = cumxor(i)
#  print(i, cx, bin(i), bin(cx))
 A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B def cumxor(P):
  x = P % 4
  if x == 0:
    return P
  elif x == 1:
    return 1
  elif x == 2:
    return P+1
  else:
    return 0 cumxor x = P % 4 x P % 4 P 4 if x == 0:
    return P
  elif x == 1:
    return 1
  elif x == 2:
    return P+1
  else:
    return 0 x == 0 x 0 return P P elif x == 1:
    return 1
   x == 1 x 1 return 1 1 elif x == 2:
    return P+1
   x == 2 x 2 return P+1 P+1 P 1 return 0 0 P P if A == B:
  print(A)
elif A == 0:
  print(cumxor(B))
else:
  print(cumxor(A-1) ^ cumxor(B))

# 試した
#def cumxor(P):
#  ret = 0
#  for i in range(0,P+1):
#    ret = ret ^ i
#  return ret 
#for i in range(0,130):
#  cx = cumxor(i)
#  print(i, cx, bin(i), bin(cx)) A == B A B print(A) print A elif A == 0:
  print(cumxor(B)) A == 0 A 0 print(cumxor(B)) print cumxor(B) cumxor B print(cumxor(A-1) ^ cumxor(B)) print cumxor(A-1) ^ cumxor(B) cumxor(A-1) cumxor A-1 A 1 cumxor(B) cumxor B B = map(int, input().split()) map(int, input().split()) B A, B = map(int, input().split()) map(int, input().split()) A def cumxor(P):
  x = P % 4
  if x == 0:
    return P
  elif x == 1:
    return 1
  elif x == 2:
    return P+1
  else:
    return 0 def cumxor(P):
  x = P % 4
  if x == 0:
    return P
  elif x == 1:
    return 1
  elif x == 2:
    return P+1
  else:
    return 0 cumxor
A, B = map(int, input().split())

def cumxor(P):
  x = P % 4
  if x == 0:
    return P
  elif x == 1:
    return 1
  elif x == 2:
    return P+1
  else:
    return 0

if A == B:
  print(A)
elif A == 0:
  print(cumxor(B))
else:
  print(cumxor(A-1) ^ cumxor(B))

# 試した
#def cumxor(P):
#  ret = 0
#  for i in range(0,P+1):
#    ret = ret ^ i
#  return ret 
#for i in range(0,130):
#  cx = cumxor(i)
#  print(i, cx, bin(i), bin(cx))

