import Data.Bits
import Data.List

main :: IO ()
main = do
  [a,b] <- map read . words <$> getLine
  print $ f a b

f :: Int -> Int -> Int
f a b = snd $ until ((b==).fst) (\(n,m) -> (n+1, m `xor` (n+1))) (a,a)