1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n, k, w, a, l;
vector <int> V;
int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a;
		V.push_back(a);
	}
	sort(V.begin(), V.end());
	for (int i = n - k - 1; i >= 0; i--) {
		if (V[i] == V[i + 1]) l++;
		else break;
	}
	cout << l+k;
}