from math import log2

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

def bitpos(x,digit=1):
  bit = x % (2**digit) // (2**(digit-1))
  pos = x % (2**digit)
  return int(bit),pos

if B == 0:
  print(0)
  exit()
else:
  max_digit=int(log2(B))+1

xor=[]
for i in range(max_digit):
  abit,apos = bitpos(A,i+1)
  bbit,bpos = bitpos(B,i+1)
  if i == 0:
    ar,br = A%4,B%4
    if (ar,br) in {(0,1),(0,2),(1,1),(1,2),(2,3),(2,0),(3,3),(3,0)}:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  
  if abit == 0 and bbit==0:
    xor.append('0')
    continue
  elif abit == 1 and bbit==0:
    if apos % 2 == 1:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  elif abit == 0 and bbit == 1:
    if bpos % 2 == 0:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  else:
    if abs(apos-bpos) % 2 == 1:
      xor.append('0')
      continue
    else:
      xor.append('1')
      continue
xor = xor[::-1]
print(int(''.join(xor),2)) from math import log2 A,B=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B def bitpos(x,digit=1):
  bit = x % (2**digit) // (2**(digit-1))
  pos = x % (2**digit)
  return int(bit),pos bitpos bit = x % (2**digit) // (2**(digit-1)) bit x % (2**digit) // (2**(digit-1)) x % (2**digit) x 2**digit 2 digit 2**(digit-1) 2 digit-1 digit 1 pos = x % (2**digit) pos x % (2**digit) x 2**digit 2 digit return int(bit),pos return int(bit),pos int(bit) int bit pos x x digit=1 digit 1 if B == 0:
  print(0)
  exit()
else:
  max_digit=int(log2(B))+1 B == 0 B 0 print(0) print 0 exit() exit max_digit=int(log2(B))+1 max_digit int(log2(B))+1 int(log2(B)) int log2(B) log2 B 1 xor=[] xor [] for i in range(max_digit):
  abit,apos = bitpos(A,i+1)
  bbit,bpos = bitpos(B,i+1)
  if i == 0:
    ar,br = A%4,B%4
    if (ar,br) in {(0,1),(0,2),(1,1),(1,2),(2,3),(2,0),(3,3),(3,0)}:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  
  if abit == 0 and bbit==0:
    xor.append('0')
    continue
  elif abit == 1 and bbit==0:
    if apos % 2 == 1:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  elif abit == 0 and bbit == 1:
    if bpos % 2 == 0:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  else:
    if abs(apos-bpos) % 2 == 1:
      xor.append('0')
      continue
    else:
      xor.append('1')
      continue i range(max_digit) range max_digit abit,apos = bitpos(A,i+1) abit bitpos(A,i+1) bitpos A i+1 i 1 apos bbit,bpos = bitpos(B,i+1) bbit bitpos(B,i+1) bitpos B i+1 i 1 bpos if i == 0:
    ar,br = A%4,B%4
    if (ar,br) in {(0,1),(0,2),(1,1),(1,2),(2,3),(2,0),(3,3),(3,0)}:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  
   i == 0 i 0 ar,br = A%4,B%4 ar A%4 A 4 br B%4 B 4 if (ar,br) in {(0,1),(0,2),(1,1),(1,2),(2,3),(2,0),(3,3),(3,0)}:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  
   (ar,br) in {(0,1),(0,2),(1,1),(1,2),(2,3),(2,0),(3,3),(3,0)} (ar,br) ar br {(0,1),(0,2),(1,1),(1,2),(2,3),(2,0),(3,3),(3,0)} xor.append('1') xor.append xor append '1' continue xor.append('0') xor.append xor append '0' continue if abit == 0 and bbit==0:
    xor.append('0')
    continue
  elif abit == 1 and bbit==0:
    if apos % 2 == 1:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  elif abit == 0 and bbit == 1:
    if bpos % 2 == 0:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  else:
    if abs(apos-bpos) % 2 == 1:
      xor.append('0')
      continue
    else:
      xor.append('1')
      continue abit == 0 and bbit==0 abit == 0 abit 0 bbit==0 bbit 0 xor.append('0') xor.append xor append '0' continue elif abit == 1 and bbit==0:
    if apos % 2 == 1:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
   abit == 1 and bbit==0 abit == 1 abit 1 bbit==0 bbit 0 if apos % 2 == 1:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
   apos % 2 == 1 apos % 2 apos 2 1 xor.append('1') xor.append xor append '1' continue xor.append('0') xor.append xor append '0' continue elif abit == 0 and bbit == 1:
    if bpos % 2 == 0:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
   abit == 0 and bbit == 1 abit == 0 abit 0 bbit == 1 bbit 1 if bpos % 2 == 0:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
   bpos % 2 == 0 bpos % 2 bpos 2 0 xor.append('1') xor.append xor append '1' continue xor.append('0') xor.append xor append '0' continue if abs(apos-bpos) % 2 == 1:
      xor.append('0')
      continue
    else:
      xor.append('1')
      continue abs(apos-bpos) % 2 == 1 abs(apos-bpos) % 2 abs(apos-bpos) abs apos-bpos apos bpos 2 1 xor.append('0') xor.append xor append '0' continue xor.append('1') xor.append xor append '1' continue xor = xor[::-1] xor xor[::-1] xor ::-1 -1 print(int(''.join(xor),2)) print int(''.join(xor),2) int ''.join(xor) ''.join '' join xor 2 A,B=map(int,input().split()) map(int,input().split()) A bbit,bpos = bitpos(B,i+1) bitpos(B,i+1) bbit ar,br = A%4,B%4 A%4 ar br = A%4,B%4 B%4 br B=map(int,input().split()) map(int,input().split()) B bpos = bitpos(B,i+1) bitpos(B,i+1) bpos xor = xor[::-1] xor[::-1] xor def bitpos(x,digit=1):
  bit = x % (2**digit) // (2**(digit-1))
  pos = x % (2**digit)
  return int(bit),pos def bitpos(x,digit=1):
  bit = x % (2**digit) // (2**(digit-1))
  pos = x % (2**digit)
  return int(bit),pos bitpos xor=[] [] xor max_digit=int(log2(B))+1 int(log2(B))+1 max_digit abit,apos = bitpos(A,i+1) bitpos(A,i+1) abit apos = bitpos(A,i+1) bitpos(A,i+1) apos
from math import log2

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

def bitpos(x,digit=1):
  bit = x % (2**digit) // (2**(digit-1))
  pos = x % (2**digit)
  return int(bit),pos

if B == 0:
  print(0)
  exit()
else:
  max_digit=int(log2(B))+1

xor=[]
for i in range(max_digit):
  abit,apos = bitpos(A,i+1)
  bbit,bpos = bitpos(B,i+1)
  if i == 0:
    ar,br = A%4,B%4
    if (ar,br) in {(0,1),(0,2),(1,1),(1,2),(2,3),(2,0),(3,3),(3,0)}:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  
  if abit == 0 and bbit==0:
    xor.append('0')
    continue
  elif abit == 1 and bbit==0:
    if apos % 2 == 1:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  elif abit == 0 and bbit == 1:
    if bpos % 2 == 0:
      xor.append('1')
      continue
    else:
      xor.append('0')
      continue
  else:
    if abs(apos-bpos) % 2 == 1:
      xor.append('0')
      continue
    else:
      xor.append('1')
      continue
xor = xor[::-1]
print(int(''.join(xor),2))