import Data.Functor
import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU
import Data.Bits

main :: IO ()
main = do
  [n,k] <- map read . words <$> getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (<'!')) <$> BS.getLine
  print $ query n k as

query :: Int -> Int -> VU.Vector Int -> Int
query !n !k !as = VU.sum $ VU.map (`xor` x) as
  where
    bitLength = finiteBitSize k - countLeadingZeros (10^12)
    bitAccum = VU.accum (+) (VU.replicate bitLength 0)
                [(b,1) | b <- [0..bitLength-1], i <- [0..n-1],
                         testBit b (as VU.! i)]
    x = VU.ifoldl' (\ !acc !i !lev -> if lev <= n `shiftR` 1 then setBit i acc
                                                             else acc)
           0 bitAccum