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()
{
    ios_base::sync_with_stdio(0);

    int N, K;
    cin >> N >> K;

    vector<int> tab(N);

    for (auto& p : tab) cin >> p;

    sort(tab.begin(), tab.end(), greater<>());

    // for (auto p : tab) cout << p << " " ;

    cout << K + count(tab.begin() + K, tab.end(), tab[K - 1]) << endl;


}