1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <algorithm>
using namespace std;
int n,k;
int main()
{
    cin>>n;
    cin>>k;
    int t[n];
    for (int i=0;i<n;i++)
        {
            cin>>t[i];
        }
    std::sort(t,t+n);
    while(n-k>=1 && t[n-k-1]==t[n-k])
        {k++;}
    cout<<k;
    return 0;
}