{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap           as IM
import           Data.List             (sort)
import           Data.Maybe            (fromJust)
main :: IO ()
main = do
  [n, k] <- readInts
  as <- readInts
  print $ solve n k as

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: Int -> Int -> [Int] -> Int
solve n k as = sum . take (l - k) . reverse $ sort es where
  l = length es
  es = IM.elems counter
  counter = foldr countup IM.empty as
  countup = IM.alter $ maybe (Just 0) (Just . (+ 1))
