import scala.io.StdIn._

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

  var count = 0
  
  if (grouped.lengthCompare(k) == 1)
    for (i <- 0 until grouped.length - k) {
      count += grouped(i)._2.length
    }

  println(count)
}
