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

using namespace std;

int main()
{
   int a,b,ilk=0,najm,i2;
   cin>>a>>b;
   long long tab[a];
   for(int i=0;i<a;i++)
   {
       cin>>tab[i];
   }
   sort(tab,tab+a);
   najm=tab[a-b];
i2=a-b;
i2--;
if(i2!=-1)
{
    while(tab[i2]==najm)
    {
        ilk++;
        i2--;
    }
}
   
cout<<b+ilk;
    return 0;
}