import Control.Monad.ST
import Data.Array.ST
import Control.Monad
import Data.Array
import Data.List

main = do
  (n:k:xx) <- map read . words <$> getLine 
  xs <- map read . words <$> getLine
  putStrLn . show $ solve n k xs

solve :: Int -> Int -> [Int] -> Int
solve n k xs = sum . take (n-k) . sort . elems $ runSTArray $ calcInST n xs


calcInST :: Int -> [Int] -> ST s (STArray s Int Int)
calcInST n xs = do
  arr <- newArray (1,n) 0
  forM_ xs $ \x -> do
    v <- readArray arr x 
    writeArray arr x (v+1)
  return arr
