1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cstdio>
#include <algorithm>

int count[128];

int main()
{
    std::fill(count, count+128, 0);
    
    int n, k, x;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &x);
        count[x]++;
    }
    int s = 0, i = 128;
    while (s < k && i > 0)
        s += count[--i];
    printf("%d\n", s);
    return 0;
}