import Data.List
main = do
  [n,k] <- map read . words <$> getLine
  ps <- sequence $ replicate n getLine
  let f 0 xs ys = 1 + f k (reverse $ sort (xs ++ ys)) []
      f _ [] ys = 0
      f m (0:xs) ys = f m xs ys
      f m (x:xs) ys = f (m-1) xs ((x-1) : ys)
  print $ f k (reverse $ sort $ map length $ group $ map head $ sort ps) []