1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <bits/stdc++.h>
using namespace std;
vector<int>a;
int n,k;
int main() {
	cin>>n>>k;
	for(int x, i=1; i<=n; i++){
		cin>>x;
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int w=a[k-1], j=k-1;
	while(a[j]==w) j++;
	cout<<j;
}