
import Data.List

answer lst k = foldl (+) 0 . map length .
  drop k . reverse $
  Data.List.sortOn length (Data.List.group $ Data.List.sort lst)

main = interact $ (++ "\n") . show . readAndAnswer . lines
  where readAndAnswer (x:y:_) = let
          [n, k] = map read $ words x
          in
          answer (map (\x -> read x :: Int) (take n $ words y)) k
