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

int main(){
	int n, k, r = 0;
	std::vector<int> score;
	std::cin >> n >> k;
	r = k;
	for(int i = 0; i < n; i++)
	{
		int t; std::cin >> t;
		score.push_back(t);
	}

	std::sort(score.begin(), score.end(), std::greater<int>());

	while(r <= n && score[r - 1] == score[r])
	{
		r++;
	}

	std::cout << r;

	return 0;
}