import Data.Array.IO
import Data.IORef
import Data.List
import Control.Monad

main = do
  (n:k:_) <- getLine >>= return . map read . words :: IO [Int]
  a <- getLine >>= return . map read . words :: IO [Int]

  arr <- newArray (1, n) 0 :: IO (IOArray Int Int)
  cnt <- newIORef 0

  forM_ a $ \x -> do
    r <- readArray arr x
    writeArray arr x (r+1)
    when (r==0) (modifyIORef cnt (+1))

  c <- readIORef cnt

  print =<< return . sum . take (c-k) . sort . (filter (/=0)) =<< getElems arr
