1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//Autor: Bartłomiej Czarkowski
#include <bits/stdc++.h>

using namespace std;

const int N = 2100;
int n, k;
int t[N];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &t[i]);
	}
	sort(t + 1, t + 1 + n);
	reverse(t + 1, t + 1 + n);
	t[n + 1] = t[n] + 1;
	while (t[k] == t[k + 1]) {
		++k;
	}
	printf("%d\n", k);
	return 0;
}