
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()

    val a = IntArray(n) { sc.nextInt() }
            .groupBy { it }
            .map { it.value.count() }
            .sorted()
    
    val sum = if (a.count() > k) a.take(a.count() - k).sum() else 0

    println(sum)
}