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
#include<bits/stdc++.h>

#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define vb vector<bool>
#define vvb vector<vb>
#define vl vector<ll>
#define endl '\n'
#define turbo ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define f first
#define s second

using namespace std;

int n, k;
vi v(1000);

int main()
{
    turbo
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        int x; cin >> x;
        v[x]++;
    }
    ll res = 0;
    for(int i = v.size()-1; i and res < k; i--)
        res += v[i];
    cout << res;
}