function Main(s) {
  var s = s.split("\n")[0].split(" ").concat(s.split("\n")[1].split(" "));
  var obj = new Map();
  var n = Number(s[0]);
  var k = Number(s[1]);
  for (var i = 2; i <= n + 1; i++) {
    if(obj.has(s[i])) {
      obj.set(s[i], obj.get(s[i]) + 1);
    } else {
      obj.set(s[i], 1);
    }
  }
  var ans = 0;
  var v = Array.from(obj.values()).sort((a, b) => a - b);
  while (v.length > k) {
    ans += v.shift();
  }
  console.log(ans);
}

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