#include<bits/stdc++.h>
using namespace std;
int n,k,ans,a,ji;
map<int,int>mp;
vector<int>v;
int main()
{
	cin>>n>>k;
	while(n--)
	{
		cin>>a;
		mp[a]++;
	}
	ji=mp.size()-k;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)v.push_back(it->second);
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		if(ji<=0)break;
		ans+=v[i];
		ji--;
	}
	cout<<ans<<endl;
	return 0;
}
