import Data.List

main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  a <- map read . words <$> getLine :: IO [Int]
  print $ n - (sum . take k . (sortBy (flip compare)) . (map length) . group . sort) a