#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  map<int, int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[a]++;
  }
  vector<int> V;
  for (map<int, int>::iterator it = A.begin(); it != A.end(); it++) {
    V.push_back(it->second);
  }
  sort(V.begin(), V.end(), greater<int>());
  long long int sum = 0;
  for (int i = K; i < V.size(); i++) {
    sum += V[i + 1];
  }
  cout << sum << endl;
  return 0;
}
