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

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);

	int n, k;
	std::cin >> n >> k;

	std::vector<int> data(n);

	for (auto& i : data) std::cin >> i;
	std::sort(data.begin(), data.end(), std::greater<int>());

	int ctr = k - 1;
	while ((ctr < n) && (data[ctr] == data[k - 1])) ctr++;
	
	std::cout << ctr;

	return 0;
}