#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int a[2000010];
int main()
{
	int n,m;
	scanf("%d %d", &n,&m);
	for (int i = 0; i < n; i++)
	{
		int q;
		scanf("%d", &q);
		a[q]++;
	}
	sort(a, a + n+1);
	int dap = 0;
	for (int i = n - m; i >= 1; i--)
		dap += a[i];
	printf("%d", dap);
}