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


int main(){
    int k, n, u;
    std::vector<int> arr;
    std::cin >> n >> k;
    if(k == n){
        std::cout << k;
        return 0;
    }
    for(int i = 0; i < n; i++){
        std::cin >> u;
        arr.push_back(u);
    }
    std::sort(arr.begin(), arr.end(), std::greater<>());
    int j = k - 1;
    while(j < n - 1 && arr[j] == arr[j+1]){
        j++;
    }
    std::cout << j+1;
    return 0;
}