import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
strToInt s = (read :: String -> Int) s

main = do

    [n,k] <- (map strToInt . words) <$> getLine
    an <- map strToInt . words <$> getLine
    
    let bn =  (group (sort an))
    let cn = reverse $ sort (map (length) bn)
    print (solve cn k)


solve :: [Int] -> Int -> Int
solve cn k = if (n <= k)
             then 0
             else sum (drop k cn)
                where n = length cn
