import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}
import MapHelper._

object Main extends App {
  val Array(n, k) = in.readLine.split(" ").map(_.toInt)
  val map = mu.HashMap.empty[Int,Int]
  in.readLine.split(" ").map(_.toInt).foreach(map.addOrUpdate(_,1))
  val g = map.keySet.size
  val ans = map.values.toArray.sorted.take(g-k).sum
  println(ans)
}

object MapHelper {
  implicit class AddOrUpdate[A](map:mu.HashMap[Int,Int]) {
    def addOrUpdate(key:Int, value:Int):mu.HashMap[Int,Int] =
    {
      if(map.contains(key)) map(key) += value
      else map += (key -> value)
      map
    }
  }
}