import Data.List
import Data.Ord

main = do
    [_, k] <- map read . words <$> getLine
    xs <- map read . words <$> getLine
    let ks = sortBy (flip compare) . map length . group $ sort (xs :: [Int])
    print . sum . drop k $ ks
