  const i = require("fs")
    .readFileSync("/dev/stdin", "utf8").split("\n");
  const inputLength = i[0].split(" ")[0];
  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)]++);
  let moveArr = arr.filter(x => !!x);
  if (moveArr.length <= Number(pirtialMax)) {
    console.log(0);
    return;
  }
  let moveCount = 0;
  while (moveArr.length > Number(pirtialMax)) {
    const minArrObj = Math.min.apply([], moveArr);
    // const maxArrObje = Math.max.apply([], moveArr);
    for (let item = 0; item < moveArr.length; item++) {
      if (moveArr[item] === minArrObj) {
        moveArr.splice(item, 1);
        break;
      }
    }
    moveCount += minArrObj;
  }
  console.log(moveCount);
