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 = reverse $ qsort (group (sort an))
    print (solve bn k)


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

comp :: [Int] -> [Int] -> Bool
comp an bn = if (length an) < (length bn)
             then True
             else False

--qsort
qsort []     = []
qsort (p:xs) = qsort lt ++ [p] ++ qsort gteq
                 where
                   lt   = [x | x <- xs, (comp x p)]
                   gteq = [x | x <- xs, not (comp x p)]