import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()
  val k = sc.nextLong()
  val a = (1..n).map { sc.nextLong() }

  val map = mutableMapOf<Long, Int>()
  for (ai in a) {
    val tmp = map.getOrElse(ai) { 0 }
    map.put(ai, tmp+1)
  }

  val values = map.values.sorted()
  val size = values.size

  if (size <= k) {
    println(0)
    return
  }

  val over = size - k
  var count = 0
  for (i in 0 until over.toInt()) {
    count += values[i]
  }

  println(count)
}
