import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Bits (testBit)
import Data.List (transpose, mapAccumL)

main :: IO ()
main = do
  [n, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    fromIntToBools :: Int -> [Bool]
    fromIntToBools = flip map is . testBit
      where
        is = [39, 38..0] :: [Int]
    k' = fromIntToBools k :: [Bool]
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    as' = transpose . map fromIntToBools $ as :: [[Bool]]
    maxF = snd . mapAccumL step (Just k') . map count $ as' :: [Int]
      where
        step :: Maybe [Bool] -> (Int, Int) -> (Maybe [Bool], Int)
        step (Just (False : bs')) (ct, _)              = (Just bs', ct)
        step (Just (_ : bs'))     (ct, cf) | ct < cf   = (Just bs', cf)
                                           | otherwise = (Nothing, ct)
        step Nothing              (ct, cf)             = (Nothing, max ct cf)
  print . fromDigitsToInt $ maxF

fromDigitsToInt :: [Int] -> Int
fromDigitsToInt = foldl step 0
  where
    step :: Int -> Int -> Int
    step ds d = 2 * ds + d
{-# INLINE fromDigitsToInt #-}

count :: [Bool] -> (Int, Int)
count = foldl step (0, 0)
  where
    step (ct, cf) b | b         = (succ ct, cf)
                    | otherwise = (ct, succ cf)
{-# INLINE count #-}

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