(* O(n log n) *)
let kNMax = 200000 in
let kInf = 300000 in
Scanf.scanf " %d %d" @@ fun n k ->
  let balls = Array.make (kNMax + 1) 0 in
  for i = 1 to n do
    let a = Scanf.scanf " %d" @@ (+) 0 in
    balls.(a) <- balls.(a) + 1
  done;
  let c = ref 0 in
  Array.iteri (fun i b -> if b = 0 then balls.(i) <- kInf else incr c) balls;
  Printf.printf "%d\n" @@
    if !c <= k then 0
    else
      (Array.sort (-) balls;
      Array.sub balls 0 (!c - k) |> Array.fold_left (+) 0)