(* O(n log n) *)
open Hashtbl
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let h = create n
let ans = ref 0
let _ =
  Array.iter (fun a -> if mem h a then replace h a @@ find h a + 1 else add h a 1) a_s;
  let c = length h in
  let cs = fold (fun _ c acc -> c :: acc) h [] |> List.sort (-) |> Array.of_list in
  for i = 0 to c - k - 1 do ans := !ans + cs.(i) done;
  Printf.printf "%d\n" !ans