A,B=list(map(int, input().split()))
if A==B:
  print(A)
  exit()
a=A//4
b=B//4

def xorsum(L):
  if len(L)==1:
    return L[0]
  a=L[0]
  for i in range(1,len(L)):
    a^=L[i]
  return a

if a==b:
  L=[A+i for i in range(B-A+1)]
  print(xorsum(L))
  exit()
c=[a*4+i for i in range(4) if i>=A%4]
d=[b*4+i for i in range(4) if i<=B%4]
print(xorsum(c)^xorsum(d)) 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 if A==B:
  print(A)
  exit() A==B A B print(A) print A exit() exit a=A//4 a A//4 A 4 b=B//4 b B//4 B 4 def xorsum(L):
  if len(L)==1:
    return L[0]
  a=L[0]
  for i in range(1,len(L)):
    a^=L[i]
  return a xorsum if len(L)==1:
    return L[0]
   len(L)==1 len(L) len L 1 return L[0] L[0] L 0 a=L[0] a L[0] L 0 for i in range(1,len(L)):
    a^=L[i]
   i range(1,len(L)) range 1 len(L) len L a^=L[i] a L[i] L i return a a L L if a==b:
  L=[A+i for i in range(B-A+1)]
  print(xorsum(L))
  exit() a==b a b A+i for i in range(B-A+1) for i in range(B-A+1) i range(B-A+1) range B-A+1 B-A B A 1 for i in range(B-A+1) A+i A i L=[A+i for i in range(B-A+1)] L [A+i for i in range(B-A+1)] print(xorsum(L)) print xorsum(L) xorsum L exit() exit a*4+i for i in range(4) if i>=A%4 for i in range(4) if i>=A%4 i range(4) range 4 i>=A%4 i A%4 A 4 if i>=A%4 a*4+i a*4 a 4 i c=[a*4+i for i in range(4) if i>=A%4] c [a*4+i for i in range(4) if i>=A%4] b*4+i for i in range(4) if i<=B%4 for i in range(4) if i<=B%4 i range(4) range 4 i<=B%4 i B%4 B 4 if i<=B%4 b*4+i b*4 b 4 i d=[b*4+i for i in range(4) if i<=B%4] d [b*4+i for i in range(4) if i<=B%4] print(xorsum(c)^xorsum(d)) print xorsum(c)^xorsum(d) xorsum(c) xorsum c xorsum(d) xorsum d def xorsum(L):
  if len(L)==1:
    return L[0]
  a=L[0]
  for i in range(1,len(L)):
    a^=L[i]
  return a def xorsum(L):
  if len(L)==1:
    return L[0]
  a=L[0]
  for i in range(1,len(L)):
    a^=L[i]
  return a xorsum L=[A+i for i in range(B-A+1)] [A+i for i in range(B-A+1)] L A,B=list(map(int, input().split())) list(map(int, input().split())) A c=[a*4+i for i in range(4) if i>=A%4] [a*4+i for i in range(4) if i>=A%4] c d=[b*4+i for i in range(4) if i<=B%4] [b*4+i for i in range(4) if i<=B%4] d b=B//4 B//4 b a=A//4 A//4 a B=list(map(int, input().split())) list(map(int, input().split())) B
A,B=list(map(int, input().split()))
if A==B:
  print(A)
  exit()
a=A//4
b=B//4

def xorsum(L):
  if len(L)==1:
    return L[0]
  a=L[0]
  for i in range(1,len(L)):
    a^=L[i]
  return a

if a==b:
  L=[A+i for i in range(B-A+1)]
  print(xorsum(L))
  exit()
c=[a*4+i for i in range(4) if i>=A%4]
d=[b*4+i for i in range(4) if i<=B%4]
print(xorsum(c)^xorsum(d))