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

using std::cout;
using std::cin;
using std::ios_base;
using std::string;
using std::sort;
using std::max;
using std::min;
using std::vector;
using std::priority_queue;
using std::stack;
using std::endl;
using std::fixed;

#define be_faster_please ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
int a[3000];

bool cmp(const int & a, const int & b)
{
    return a > b;
}

int main()
{
    be_faster_please;
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i];
	sort(a, a + n, cmp);
	k--;
    while(k + 1 < n && a[k] == a[k + 1])
        k++;
    cout << k + 1;
    return 0;
}