import qualified Data.ByteString.Char8 as B
import Data.ByteString.Char8 (ByteString)
import qualified Data.Map as M
import Data.Map (Map)
import Data.List (sortBy)
 
main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  as <- B.words <$> B.getLine
  print $ solve k $ count as
 
count :: [ByteString] -> Map ByteString Int
count = foldr ins M.empty
  where ins k m = M.insertWith (+) k 1 m
 
solve :: Int -> Map ByteString Int -> Int
solve k = sum . drop k . descSort . M.elems

descSort :: [Int] -> [Int]
descSort = sortBy (flip compare)