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 <algorithm>
#include <vector>
#include <cstdio>

const int MAXV = 120;

int main() {

    int n, k;
    scanf("%d %d", &n, &k);
    std::vector<int> counts(MAXV + 1, 0);

    int t;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &t);
        counts[t]++;
    }

    int c = 0;
    for (int i = 120; i >= 0; i--)
    {
        if (c >= k)
            break;
        c += counts[i];
    }

    printf("%d\n", c);
    
    return 0;
}