1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 2005;

int n, k, tab[N], i;

bool cmp(int a, int b) {
	return a > b;
}

int main() {
scanf("%d %d", &n, &k);
for (i=0;i<n;i++) scanf("%d", &tab[i]);
sort(tab, tab + n, cmp);
while (k < n && tab[k - 1] == tab[k]) k++;
printf("%d\n", k);
return 0;
}