let rec take n = function
  | [] -> []
  | x :: xs ->
      if n <= 0 then []
      else x :: take (n - 1) xs

module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let as_ = Array.init n @@ fun _ ->
    Scanf.scanf "%d " @@ fun a -> a in
  Array.fold_left (fun m a ->
    IntMap.add a (1 + try IntMap.find a m with Not_found -> 0) m) IntMap.empty as_
  |> IntMap.bindings
  |> List.sort (fun (_, n) (_, m) -> compare n m)
  |> (fun xs -> take (List.length xs - k) xs)
  |> List.map snd
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n"


