(* O(n log n) *)
let kNMax = 200000 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 incr c) balls;
  Printf.printf "%d\n" @@
  (Array.sort (fun x y -> y - x) balls;
  Array.sub balls k (kNMax + 1 - k) |> Array.fold_left (+) 0)