'use strict'

function main(s) {

  s = s.split('\n');
  const K = Number(s[0].split(' ')[1]);
  const balls = s[1].split(' ').map(el => Number(el));
  const countList = [];

  balls.forEach((x, i, self) => {
    if(self.indexOf(x) === i) {
      countList.push({key: x, count: 1});
    } else {
      countList.forEach((y, j, self) => {
        if (x === y.key) y.count += 1;
      })
    }
  });

  countList.sort((a, b) => b.count - a.count);

  const changeList = countList.slice(K);
  let answer = 0;
  if (changeList) {
    changeList.forEach((el) => {
      answer += el.count;
    })
  }

  console.log(answer);
}

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