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