object Main extends App {
  val Array(n,k) = readLine.split(" ").map{_.toInt}
  val a = readLine.split(" ").map{_.toInt}
  var map = Map.empty[Int,Int]
  a.foreach{v => map = map.updated(v,map.getOrElse(v,0)+1)}
  
  val dif = Array(map.size - k,0).max
  
  println(map.values.toArray.sortWith{(a,b) => a <= b}.take(dif).sum)
}