fun main(arr:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val balls = readLine()!!.split(" ").map { it.toInt() }
    val ballCount = mutableMapOf<Int, Int>()
    balls.forEach{
        if(ballCount.containsKey(it)) {
            ballCount[it] = ballCount[it]!!+1
        } else {
            ballCount[it] = 1
        }
    }
    val ans = ballCount.toList().sortedBy { it.second }.take(Math.max(0, ballCount.size - k)).sumBy { it.second }
    println(ans)
}
