#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int A;
  int answer = 0;
  vector<int> a(n+1);
  for(int i = 0;i < n;i++){
    cin >> A;
    a[A]++;
  }
  sort(a.begin(),a.end());
  for(int i = 0;i < n-k+1;i++){
    answer += a[i];
  }
  cout << answer << endl;
}