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

constexpr int N = 2001;
int T[N];

int main () {
	int n, k; cin>>n>>k;
	for (int i=0; i<n; ++i)
		cin>>T[i];
		
	sort (T, T+n, greater <int>());
	k--;
	int s = T[k];
	while (T[k]==s) 
		k++;
	
	cout<<k;
}