import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.IntMap as IM
import Data.List

type Map = IM.IntMap Int

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

countUp :: Int -> Int -> Map -> Map
countUp = IM.insertWithKey f
  where f _ new old = old + new

build :: [Int] -> Map -> Map
build [] m = m
build (a:as) m = build as $ countUp a 1 m

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  as <- readIntsLine
  let res = sortOn snd . IM.toList $ build as IM.empty
  print . sum . map snd $ take (length res - k) res