fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val A = listOfInt()
    val M = A.groupBy { it }.map { it.key to it.value.size }.sortedBy { it.second }.toTypedArray()
    var k = M.size
    var ans = 0
    for (n in 0 until M.size) {
        if  (k <= K) break
        ans += M[n].second
        k -= 1
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map(String::toLong)
