"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    const ball = [...Array(N)].fill(0);
    
    for(let i=0; i<N; i++) {
        ball[A[i]-1]++;
    }
    
    ball.sort((a,b)=>b-a);
    
    const temp = ball.filter(n=>n!==0); 
    
    if(temp.length <= K) {
        console.log(0);
    } else {
        console.log(temp.slice(-(K-1)).reduce((m,n)=>m+n));
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));