object Main extends App {
  println("a")
  val Array(n,k) = readLine.split(" ").map{_.toInt}
  val a = readLine.split(" ").map{_.toInt}
  var map = Map.empty[Int,Int]
  for(v <- a) map = map.updated(v,map.getOrElse(v,0)+1)
  

  println(map.toArray.sortWith{case ((v1,n1),(v2,n2)) => n1 <= n2}.toList.take(Array(map.size-k,0).max).foldLeft(0){(acc,p) => acc + p._2})
}