import qualified Data.IntMap as M
import Data.List
 
main = do
  [n, k] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  let dict = mkDict as
  print $ solve k dict
 
mkDict :: [Int] -> M.IntMap Int
mkDict [] = M.empty
mkDict (x:xs) = M.insertWith (+) x 1 $ mkDict xs
 
solve :: Int -> M.IntMap Int -> Int
solve k dict = sum . drop k . sortOn negate $ M.elems dict