import scala.io.StdIn

object Main extends App {

  val Array(n, k) = StdIn.readLine().split(' ').map(_.toLong)
  val a = StdIn.readLine().split(' ').map(_.toLong)

  val g = a.groupBy(k => k).map(e => (e._1 , e._2.size)).toList.sortBy(p => p._2)
  def loop(lst: List[(Long, Int)], cnt: Int): Int = {
    if(lst.isEmpty || lst.size <= k) {
      cnt
    } else {
      loop(lst.tail, cnt + lst.head._2)
    }
  }
  println(loop(g, 0))
}