#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
ll MAX_N = 200005;

int main() {
  ll n, k;
  ll a[MAX_N];
  ll c[MAX_N];
  scanf("%lld %lld", &n, &k);
  for (ll i=0; i<n; i++) {
    scanf("%lld", &a[i]);
    c[a[i]]++;
  }
  sort(c, c+n+1, greater<ll>());
 
  ll s = 0;
  for (ll i=0; i<k; i++) {
    s += c[i];
  }

  printf("%lld\n", max(0ll, n-s));

  return 0;
}
