import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord 

main :: IO ()
main = breads >>= main' . last
    where
        main' k = breads >>= print . solve k

solve :: Int -> [Int] -> Int 
solve k = condf . sortBy (comparing length) . group . sort
    where
        condf xs
            | n > k = foldl' ff 0 $ take (n - k) xs
            | otherwise = 0
            where
                n = length xs
                ff acc x = acc + length x

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)