#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 200005
using namespace std;

int n, k, s, c[N];
int main()
{
	int i, t;
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		scanf("%d", &t);
		if (++c[t] == 1) k--;
	}
	sort(c, c + n + 1);
	for (i = 0; i < n && k < 0; i++) {
		if (!c[i]) continue;
		s += c[i], k++;
	}
    cout << s << endl;
    return 0;
}