object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN, datK) = readLine.split(" ").map(_.toInt)
    val datA = readLine.split(" ").map(_.toInt)

    val scA = datA.groupBy(identity).mapValues(_.length).toList.sortBy(_._2)
    val rewriteK = math.max(0, scA.length - datK)

    def countup(result: Int, num:Int, ls: List[(Int, Int)]): Int = {
      if (num == 0) result
      else countup(result + ls.head._2, num - 1, ls.tail)
    }
    val ans = countup(0, rewriteK, scA)

    println(ans)
  }
}
