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

int main() {
	int N, K;
	std::cin >> N >> K;
	std::vector<std::pair<int,int> > V(N + 1, {0, 0});
	for(int i = 0; i < N; i++) {
		int a;
		std::cin >> a;
		V[a].first++;
		V[a].second = a;
	}
	std::sort(V.rbegin(), V.rend());
	int ans = 0;
	int idx = 0;
	while(K>0&&idx<=N){
		K-=V[idx].first;
		if(V[idx].first > 0) ans++;
		idx++;
	}
	std::cout << ans << std::endl;
	return 0;
}