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

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