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
27
28
29
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <time.h>
#include <queue>

using namespace std;

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	vector<int> a;
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		a.push_back(x);
	}
	sort(a.rbegin(), a.rend());
	int res = k;
	while (res < n && a[res] == a[k - 1]) {
		++res;
	}
	printf("%d\n", res);
	return 0;
}