#include <bits/stdc++.h>
using namespace std;

int main(void) {
  int n, k;
  int tmp;
  cin >> n >> k;
  vector<int> v(200001, 0);
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    v[tmp]++;
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  v.erase(v.begin(), v.begin() + k);
  int result = 0;
  for (const int &e : v) result += e;

  cout << result << endl;
  return 0;
}