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

int a[201000],n,x,k,ans;

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