import Data.List
import Data.Array
import Data.Maybe
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt
 
solve :: Int -> Int -> [Int] -> Int
solve n k ls = sum $ 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)