import Data.List

main = do
  str <- getLine
  let [n, k] = map read (words str) ::[Int]
  str <- getLine
  let a = take n $ map read (words str) ::[Int]
  let list = sort $ map (\x -> length x) $ group $ sort a
  if length list <= k
    then print 0
    else print $ sum $ take ((length list) - k) list
  