
open Scanf
open Printf

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec take n xs_ = match xs_ with
  | (x::xs) when n > 0 -> x :: take (n-1) xs
  | _ -> []

let group_len xs_ =
  let rec f c x ys =
    match ys with
    | [] -> [c]
    | (y::ys') -> if x = y then f (c+1) x ys' else c :: f 1 y ys' in
  match xs_ with
    | [] -> []
    | (x::xs) -> f 1 x xs

let () =
  let n = read_int () in let k = read_int () in
  let ls = read_ints n |> List.sort (-) |> group_len |> List.sort (-) in
  take (List.length ls - k) ls |> List.fold_left (+) 0 |> printf "%d\n"
