object Main extends App {
  val Array(n,k) = readLine.split(" ").map{_.toInt}
  val a = readLine.split(" ").map{_.toInt}
  val memo = new Array[Int](n+1)
  a.foreach{v => memo(v) = memo(v) + 1}
  
  val memo2 = memo.sorted.toList.filter{_ != 0}
  val dif = Array(memo2.length - k,0).max
  
  println(memo2.take(dif).sum)
}