import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.StreamTokenizer
import java.util.*

class A

fun main( args: Array<String> ) {
    val st = StreamTokenizer( BufferedReader( InputStreamReader( System.`in` ) ) )
    val n = st.nextInt()
    val k = st.nextInt()
    val a = IntArray( n, { st.nextInt() } )
    a.sort()
    val s = ArrayList<Int>( n )
    run {
        var l = 0
        for ( i in 0 .. a.size ) {
            if ( i == a.size || a[i] != a[l] ) {
                s.add( i - l )
                l = i
            }
        }
    }
    s.sort()
    var r = 0
    for ( i in 0 until s.size - k ) {
        r += s[i]
    }
    println( r )
}

private fun StreamTokenizer.nextInt(): Int {
    nextToken()
    return nval.toInt()
}
