function main(input) {
  input = input.split('\n');
  const NK = input[0].split(' ').map(n => parseInt(n, 10));
  const N = NK[0],
        K = NK[1];
  const A = input[1].split(' ').map(n => parseInt(n, 10));

  const targets = Array.from(new Set(A))
    .map(i => A.filter(j => j === i).length)
    .sort((a, b) => {
      if (a > b) return -1;
      if (a < b) return 1;
      return 0;
    })
    .slice(K);

  const answer = (targets.length > 0) ? targets.reduce((a, b) => a + b) : 0;
  console.log(answer);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
