#include <bits/stdc++.h>
using namespace std;
int A[200005],n,k,sum,B[200005],m,ans;
int cmp(int i,int j) {return i<j;}
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1; i<=n; i++ )scanf("%d",&A[i]);
	sort(A+1,A+n+1,cmp);
	for (int i=1; i<=n; i++)
	{
	  if (i!=1 && A[i]==A[i-1]) B[m]++; else {B[++m]=1;}
	}
	sort(B+1,B+m+1,cmp);
	for (int i=1; i<=m-k; i++) ans+=B[i];
	cout<<ans;
	return 0;
}