
fun main(arr:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val numbers = readLine()!!.split(" ").map { it.toInt() }
    val numberCount = mutableMapOf<Int, Int>()
    for(i in numbers) {
        numberCount[i] = (numberCount[i]?:0) + 1
    }
    if(numberCount.size <= k) {
        println(0)
        return
    }
    val tmp = numberCount.toList().sortedBy { it.second }.take(numberCount.size - k).map { it.second }.sum()
    println(tmp)

}

