import Data.List
import Data.Array
import Data.Maybe
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt
 
solve :: Int -> [Int] -> Int
solve k = sum . drop k . sortBy (flip compare) . change . sortBy compare
 
change :: [Int] -> [Int]
change [] = []
change (x:xs) = go x 1 xs
    where go n c [] = [c]
          go n c (x:xs)
            | n == x = go n (c+1) xs
            | otherwise = c : go x 1 xs 
 
main :: IO ()
main = do
    [n, k] <- getInts
    ls <- getInts
    print (solve k ls)