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

int a[2005];

int main () {
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a+1, a+1+n);
	
	int minn = a[n-k+1];
	
	int wyn = 0;
	for (int i = n; i >= 1; i--) {
		if (a[i] >= minn)
			wyn++;
	}
	cout << wyn;
	
	return 0;
}