function Main(input){
  var arr = input.split('\n');
  arr.pop();
  var k = arr[0].split(' ').map(a=>Number(a))[1];
  var a = arr[1].split(' ').map(a=>Number(a));
  var p = [];
  for(var i=0;i<a.length;i++){
    if(isNaN(p[a[i]-1])){
      p[a[i]-1]=1;
    }else{
      ++p[a[i]-1];
    }
    if((isNaN(p[i]))&&(i<Math.max(...a))){
      p[i]=0;
    }
  }
  var q=p.sort().filter(a=>a!=0);
  var result=0;
  for(var i=0;i<q.length-k;i++){
    result+=q[i];
  }
  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));