import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] NK = readln.chomp.split.to!(int[]);
  int N = NK[0],
      K = NK[1];
  int[] A = readln.chomp.split.to!(int[]);
  int[int] cs;
  int ans;

  foreach (a; A) {
    if (a in cs) {
      cs[a]++;
    } else {
      cs[a] = 1;
    }
  }

  int[] ks = cs.keys.sort!((a, b) => cs[a] < cs[b]).array;
  ulong k = cs.keys.length;
  size_t idx;

  while (k > K) {
    k--;
    ans += cs[ks[idx++]];
  }

  writeln(ans);
}
