1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <bits/stdc++.h>

using namespace std;

int n, k;
int A[2000 + 10];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i) cin >> A[i];

	sort(A + 1, A + n + 1, [](int a, int b){ return a > b; });

	A[n + 1] = 1000;
	for (; A[k] == A[k + 1]; ++k) {};

	cout << k << '\n';
}