1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>

using namespace std;


int main() {
    int n, k;
    vector <int> v;
    
    scanf("%d %d", &n, &k);
    v.resize(n);
    
    for(int i = 0; i < n; ++i)
        scanf("%d", &v[i]);
        
    sort(v.begin(), v.end());
    
    vector <int>::iterator low = lower_bound(v.begin(), v.end()-k, *(v.end()-k));
    
    printf("%ld\n", v.end() - low);
    
    return 0;
}