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
42
43
44
45
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define BCK(i, n) for(int i = n-1; i >= 0; i--)
#define FWD(i, a, b) for(int i = a; i < b; i++)
#define pb push_back
#define st first
#define nd second
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int, int>
#define pll pair<long long, long long>
#define vpi vector<pi>
#define vpll vector<pll>
#define mp(a, b) make_pair(a,b)
using namespace std;
typedef long long LL;
typedef double ld;
const LL p = 1000000007;


int main() {
    std::ios::sync_with_stdio(false);
    int n, m, t, k, p;
    vector<int> points;

    cin >> n >> k;
    for(int i=0; i<n; i++) {
        cin >> p;
        points.push_back(p);
    }

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

    int lastRewardedPoints = points[k-1];
    int allRewardedContestants = k;
    for (int i=k; k<n; i++) {
        if (lastRewardedPoints > points[i]) {
            break;
        }
        allRewardedContestants += 1;
    }

    cout << allRewardedContestants << endl;
    return 0;
}