import qualified Data.ByteString.Char8 as B
import qualified Data.Map.Strict as M
import Data.List
 
main = do
  [n, k] <- map read . words <$> getLine
  as <- B.words <$> B.getLine
  let dict = mkDict as
  print $ solve k dict
 
mkDict = foldr (\x y -> M.insertWith (+) x 1 y) M.empty
 
solve k dict = sum . drop k . sortOn negate $ M.elems dict