import           Control.Monad (when)
import           Data.Bits     (bit, finiteBitSize, testBit, xor, (.&.))
import           Data.List     (partition)

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  when (length as /= n) $ error "length as /= n"
  print $ g k as

f :: Int -> [Int] -> Int
f x = sum . map (`xor` x)

g :: Int -> [Int] -> Int
g k xs =
  let
    xBits =
      map (\i -> if majority $ map (`testBit` i) xs then 0 else bit i) [0 .. finiteBitSize (undefined :: Int)]
    x = sum xBits .&. k
  in
    f x xs

majority :: [Bool] -> Bool
majority bs =
  let
    (trues, falses) = partition id bs
  in
    length trues > length falses
    -- k 以下という条件があるため、 1 と 0 が同数のときは 0 になったほうが有利
