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

const int maxn = 2e5+1;



int cnt[maxn];
int main()
{
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i)
    {
      int a;
      scanf("%d", &a);
      cnt[a] += 1;
    }
  sort(cnt, cnt+maxn, greater<int>());
  int ans = n;
  for (int i = 0; i < k; ++i)
    ans -= cnt[i];
  printf("%d\n", ans);
}
