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

using namespace std;

#define M 2007

int n, k;
int t[M];

int main() {
	scanf("%d%d", &n, &k);
	for (int i=0; i<n; i++) scanf("%d", &t[i]);
	sort(t, t+n, greater<int>());

	int res=k;
	for (; res<n && t[res]==t[k-1]; res++);

	printf("%d\n", res);
	return 0;
}