import scala.collection.mutable.HashMap
import scala.io.StdIn

object Main extends App {

  val map = HashMap.empty[Int,Int]

  val Array(n, k) = StdIn.readLine.split(" ").map(_.toInt)
  val seq = StdIn.readLine.split(" ").map(_.toInt)

  seq.foreach(i => {
    if(!map.contains(i)) map += i -> 1
    else map += i -> (map(i)+1)
  })

  val s = map.values.toArray.sorted
  val g = math.max(s.size - k, 0)
  val ans = s.take(g).sum
  
  println(ans)
}