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

int main(){

	ll N,K;
	cin >> N >> K;
	map<ll,ll> ma;
	for(int i=0;i<N;i++){
		ll A;
		cin >> A;
		ma[A]++;
	}
	ll cnt = ma.size();
	vector<ll> v;
	for(auto x:ma){
		v.push_back(x.second);
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	for (int i = 0; i < (cnt-K); ++i){
		ans += v[i];
	}
	cout << ans << endl;
}