fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun <T> Iterable<T>.groupingCount(): Map<T, Int> {
    val map = mutableMapOf<T, Int>()
    for (element in this) {
        map[element] = map.getOrElse(element) { 0 } + 1
    }
    return map
}

fun main(args: Array<String>) {
    val (n, k) = readInts()
    val aa = readInts().groupingCount()
    if (aa.size <= k) {
        println(0)
        return
    }
    println(aa.toList()
        .sortedBy(Pair<Int, Int>::second)
        .subList(0, aa.size - k)
        .sumBy(Pair<Int, Int>::second))
}
