module Main where

import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

readi b | Just (n, _) <- B.readInt b = n

main :: IO ()
main = do
    [_, k] <- fmap readi . B.words <$> B.getLine :: IO [Int]
    as <- fmap readi . B.words <$> B.getLine :: IO [Int]
    let m1 = sortOn length . group . sort $ as
    case length m1 of
        s | s <= k    -> print 0
          | otherwise -> do
                let bs = take (s - k) m1
                print . sum . fmap length $ bs