import std.stdio,
       std.string,
       std.conv,
       std.algorithm;

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

  for (int i = 0; i < N; i++) {
    mp[A[i]]++;
  }
  
  int ans;
  int[] mpv = mp.values;
  sort(mpv);
  for (int i = 0; i < cast(long)mp.length - K; i++) {
    ans += mpv[i];
  }

  writeln(ans);
}
