#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using vi = vector<int>;

int main() {
	int n, k;
	cin >> n >> k;
	vi a(200000,0);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		a[x]++;
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < 200000 - k; i++) {
		ans += a[i];
	}
	cout << ans << endl;

}