import scala.collection.mutable

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, K = sc.nextInt()
  val counts = mutable.Map[Int, Int]()
  for (_ <- 1 to N) {
    val a = sc.nextInt()
    counts.update(a, counts.getOrElse(a, 0) + 1)
  }
  val diff = counts.keys.size - K
  println(if (diff <= 0) 0 else counts.values.toList.sorted.take(diff).sum)
}
