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>

using namespace std;

const int MAXN = 2000 + 1;

int n, k;
int a[MAXN];

int main() {
    scanf("%d %d", &n, &k);
    k--;

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    a[n] = -1;

    sort(a, a + n);
    reverse(a, a + n);
    while (a[k] == a[k + 1]) k++;
    printf("%d\n", k + 1);
}