1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<uint32_t> nbrs(n);
	for (auto& nb : nbrs) cin >> nb;
	sort(nbrs.rbegin(), nbrs.rend());
	int ans = k - 1;
	while (ans < nbrs.size() && nbrs[ans] == nbrs[k-1] ) ans++;
	cout << ans;
}