const i = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");
const pirtialMax = i[0].split(" ")[1];
const inputArr = i[1].split(" ");
const arr = new Array(200000);
arr.fill(0);
inputArr.forEach(x => arr[Number(x)]++);
const moveArr = arr.filter(x => !!x);
if (moveArr.length <= Number(pirtialMax)) {
  console.log(0);
  return;
}
var moveCount = 0;
while (moveArr.length > Number(pirtialMax)) {
  const minArrObj = Math.min.apply([], moveArr);
  // const maxArrObje = Math.max.apply([], moveArr);
  for (var item = 0; item < moveArr.length; item++) {
    if (moveArr[item] === minArrObj) {
      moveArr.splice(item, 1);
      break;
    }
  }
  moveCount += minArrObj;
}
console.log(moveCount);