1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <algorithm>

const int max_size = 2020;

int n;
int k;
int a[max_size];

int ref;
int itr;

int main(){
        std::cin >> n >> k;

        for(int i = 0; i < n; i++){
                std::cin >> a[i];
                a[i] *= -1;
        }
        std::sort(a, a + n);

        ref = a[k - 1];
        itr = k;

        while(itr < n && a[itr] == ref)
                itr++;

        std::cout << itr << "\n";

        return 0;
}