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

int main()
{
    std::ios_base::sync_with_stdio(false);
    int k,n;
    std::cin>>k>>n;
    std::vector<int> results;
    for(int i=0;i<k;++i)
    {
        int result;
        std::cin>>result;
        results.push_back(result);
    }

    std::sort(results.begin(),results.end(), std::greater<int>());

    int res = results[n-1];
    std::vector<int>::iterator up;
    up= std::upper_bound(results.begin(), results.end(), res, std::greater<int>());
    std::cout<< (up - results.begin()) <<std::endl;
    return 0;
}