1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> A(n);
	for (int i=0; i<n; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end(), greater<int>());
	cout << upper_bound(A.begin(), A.end(), A[k-1], greater<int>()) - A.begin() << "\n";
	return 0;
}