import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.PriorityQueue

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val A = new Array[Int](N)

  for(i <- 0 until N)
    A(i) = in.next().toInt

  val b = A.sorted

  /*  降順  */
  val pq = new PriorityQueue[Int]


  var now = b(0)
  var cnt = 1
  var num = 0
  for(i <- 1 until N) {
    if(now != b(i)) {
      pq.enqueue(-cnt)
      now = b(i)
      cnt = 1
      num += 1
    }
    else {
      cnt += 1
    }
  }
  num += 1
  pq.enqueue(-cnt)

  var ans = 0
  while(num > K) {
    val now = -pq.dequeue
    ans += now
    num -= 1
  }
  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
