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>
using namespace std;

#define FOR(i,a,b) for(int (i)=(int)(a); (i)!=(int)(b); ++(i))

int n, k, count[121];
int main() {
    scanf("%d %d", &n, &k);
    FOR(i,0,121) count[i] = 0;
    FOR(i,0,n) {
        int a;
        scanf("%d", &a);
        ++count[a];
    }

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

    printf("%d\n", result);
}