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