import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
--import Debug.Trace

main :: IO ()
main = readLine >>= print . solve

solve :: [Int] -> Int
solve [a, b] = foldl' ff 0 $ map (2 ^) [0..40]
    where
        ff acc i
            | odd c1 = acc + i
            | otherwise = acc
            where
                c1 = bc1 - ac1
                ac1 = count i . max 0 $ a - 1
                bc1 = count i b
                
count :: Int -> Int -> Int
count i x
    | odd r = i * (r `div` 2) + m
    | otherwise = i * (r `div` 2)
    where
        (r, m) = (x + 1) `divMod` i
                

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine