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
#include <cstdio>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;
 
int main()
{
    int n, k ,a;
    scanf("%d%d",&n,&k);
    vector<int> v;
    for (int i=0; i<n; i++)
    {
        scanf("%d",&a);
        v.push_back(-a);
    }
    sort(v.begin(), v.end());

    while (k < n && v[k-1] == v[k])
        k++;

    printf("%d\n",k);
}