import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Bits (xor)

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

f :: Int -> Int -> Int
f i j = g i `xor` g (succ j)
{-# INLINE f #-}

g :: Int -> Int
g i | r == 0    = 0
    | r == 1    = i `xor` 1
    | r == 2    = 1
    | otherwise = i
  where
    r = i `mod` 4
{-# INLINE g #-}

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
