{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.Array.Unboxed    as A
import qualified Data.ByteString.Char8 as BC
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) cs where
  cs = sort hist
  hist = A.elems $ (A.accumArray (+) 0 (1, n) [(i, 1) | i <- as] :: A.UArray Int Int)
  l = length cs
