function Main(s) {
  var s = s.split("\n")[0].split(" ").concat(s.split("\n")[1].split(" "));
  var n = Number(s[0]);
  var k = Number(s[1]);
  var arr = new Array(n + 1).fill(0);
  for (var i = 2; i <= n + 1; i++) {
    arr[s[i]]++;
  }
  var ans = 0;
  var v = arr.sort((a, b) => a - b);
  while (v.length > k) {
    ans += v.shift();
  }
  console.log(ans);
}

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