import Data.List
 
getInts :: IO [Int]
getInts = (map read . words) <$> getLine
 
solve :: Int -> Int -> [Int] -> Int
solve n k ls = foldl (+) 0 $ take (length v - k) v
    where v = sort $ map length $ group (sort ls)
 
main :: IO ()
main = do
    [n, k] <- getInts
    ls <- getInts
    print $ solve n k ls