1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <bits/stdc++.h>
using namespace std;

const int N = 2005;

int n, k;
int tab[N];

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