import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import Data.Char
import Data.List

step :: MP.Map Int Int -> Int -> MP.Map Int Int
step m x =
    case MP.lookup x m of
        Just _ -> MP.adjust (+1) x m
        Nothing -> MP.insert x 1 m

solve :: [Int] -> Int -> Int
solve xs k
    | length xs <= k = 0
    | otherwise = m + solve ds k
        where
            m = minimum xs
            ds = delete m xs

main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$>  B.getLine
    let m = VU.foldl' step MP.empty as
    let vs = MP.foldl (flip (:)) [] m 
    print $ solve vs k