import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val Array(n, k) = readLine().split(" ").map(_.toInt)
    val a: Array[Int] = readLine().split(" ").map(_.toInt)
    //println(solve(n, k, a))
    println(solve(n,k,a))
    //count(a).map((x) => print(x))

  }

  def count(ints: Array[Int]): List[(Int, Int)] = {
    val gen = ints.sortWith(_<_)
    var ans: List[(Int, Int)] = Nil
    var temp = (ints(0), 0)

    for(x <- gen){
      if(x == temp._1) temp = (temp._1, temp._2 + 1)
      else {
        ans = temp :: ans
        temp = (x, 1)
      }
    }
    temp :: ans
  }


  def solve(i: Int, i1: Int, ints: Array[Int]): Int = {
    val a = count(ints)
    a.sortBy(_._2).take(if(a.length > i1) a.length - i1 else 0).foldLeft(0)((acc, x) => acc + x._2 )
  }


}
