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

const int N = 2000 + 5;

int nextInt() { int n; scanf("%d", &n); return n; }

int data[N];

int main() {
	int n = nextInt();
	int k = nextInt();
	for (int i=0; i<n; ++i) data[i] = nextInt();

	std::sort(data, data + n);
	std::reverse(data, data + n);

	int res = k - 1;
	while (res < n && data[k - 1] == data[res]) ++res;

	printf("%d\n", res);

	return 0;
}