import scala.io.StdIn._

object Main extends App {
  val Array(n, k) = readLine().split(" ").map(_.toInt)
  val l = readLine().split(" ")
    .map(_.toInt)
    .groupBy(i => i)
    .toList
    .sortBy(_._2.length)

  var count = 0

  for (i <- 0 until l.length - k) {
    count += l(i)._2.length
  }

  println(count)
}
