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

int main()
{
	int cnt[200005] = {};
	int N, K;

	cin >> N >> K;
	for ( int i = 0; i < N; i++ ) {
		int A;
		cin >> A; --A;
		cnt[A]++;
	}
	sort(cnt, cnt + N);
	int sum = 0;
	for ( int i = 0; i < N - K; i++ ) {
		sum += cnt[i];
	}

	cout << sum << endl;
	return ( 0 );
}
