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

#define ll long long
#define pb push_back
#define nd second
#define st first
#define mp make_pair
bool cmp(int a, int b)
{
    return a>b;
}
int tab[2009];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, wyn=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>tab[i];
    }
    sort(tab, tab+n, cmp);
 //   for(int i=0;i<n;i++) cout<<tab[i]<<" ";
    for(int i=0;i<n;i++){
        if(k!=0){
            k--;
            wyn++;
        }
        else{
            while(tab[i]==tab[i-1]&&i!=n)
            {
                wyn++;
                i++;
            }
            break;
        }
    }
    cout<<wyn;
}