fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }.groupBy { it }.entries.sortedBy { it.value.size }

    var cnt = 0
    aa.take(Math.max(0, aa.size-k)).forEach {
        cnt += it.value.size
    }

    println(cnt)
}