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
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <vector>
#include <algorithm>

#ifdef TEST_MODE
#include <fstream>
#endif

using namespace std;

int main() {
#ifdef TEST_MODE
    std::ifstream in("kos01.in"); std::cin.rdbuf(in.rdbuf());
#endif
    std::ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<int> points;
    for ( int i = 0; i < n; ++i ) {
        int point;
        cin >> point;
        points.push_back(point);
    }
    
    sort(points.begin(), points.end(), greater());
    
    int result = k;
    int p = points[k-1];
    for ( int i = k; i < n; ++i ) {
        if ( p == points[i] ) {
            result++;
        } else {
            break;
        }
    }
    
    cout << result << endl;
    
    return 0;
}