import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val n  = sc.nextInt
  val k  = sc.nextInt

  val al = List.fill(n)(sc.nextInt)

  val res = al.foldLeft(new Array[Int](200000)){(arr, a)=>
    val v = arr(a - 1)
    arr.update(a - 1, v + 1)
    arr
  }.zipWithIndex.filter(_._1 != 0).sortWith((a1,a2) => a1._2 > a2._2).dropRight(k).map(_._1).sum

  println(res)
}