import Control.Monad
import Data.List

data Fuck a = Fuck a deriving(Show)

main = do
    [n, k] <- map read <$> words <$> getLine
    bds <- replicateM n getLine
    let bds2 = map (\xs -> Fuck xs) bds
    let temp = filterM (\x -> [True, False]) bds
    -- putStrLn $ show temp
    let temp1 = head $ sort $ filter (\xs -> length xs == k) $ map (foldl1 (\xs ys -> xs ++ ys)) $ filter (\xss -> not $ length xss == 0) temp
    
    putStrLn temp1
    -- putStrLn $ show temp1
    
    return 2