fun main(args: Array<String>) {
  val (n, k) = readLine()!!.split(" ").map { it.toInt() }
  val aList = readLine()!!.split(" ").map { it.toInt() }
  val g = aList.groupBy { it }
  val p = g.map { it.key to it.value.count() }.sortedBy { it.second }
  val cnt = p.size - k
  if (cnt < 1) {
    println(0)
    return
  }
  var ans = 0
  for (i in 0 until cnt) {
    ans += p[i].second
  }
  println(ans)
}
