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)}

  println(map.toArray.sortWith{case ((v1,n1),(v2,n2)) => n1 >= n2}.toList.drop(k).map{_._2}.sum)
}