1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define INT(x) int x; scanf("%d", &x)

int a[2000];

int main() {
	INT(n);
	INT(k);
	REP(i,n) scanf("%d", &a[i]);
	sort(a, a + n, greater<int>());
	while (k < n && a[k] == a[k - 1]) ++k;
	printf("%d\n", k);
}