import scala.io.StdIn

object Main extends App {

  val Array(n, k) = StdIn.readLine().split(' ').map(_.toLong)
  val a = StdIn.readLine().split(' ').foldLeft(Map.empty[String, Int]){ (acc ,c) =>
    if(acc.contains(c)){
      acc.updated(c, acc(c) + 1)
    } else {
      acc ++ Map(c -> 1)
    }
  }.toList.sortBy( p => -1*p._2)

  def loop(lst: List[(String, Int)], sum: Int, cnt: Int): Int = {
    if(lst.isEmpty || cnt == k) {
      sum
    } else {
      loop(lst.tail, sum + lst.head._2, cnt + 1)
    }
  }
  println(n - loop(a, 0, 0))
}