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

using namespace std;

int main(int argc, char** argv) {
  int n, k;
  scanf("%d%d", &n, &k);
  int a[2005];
  for(int i=0;i<n;i++) {
    scanf("%d", &(a[i]));
  }
  sort(a, a+n, greater<int>());
  int i = k - 1;
  while ((i < n - 1) && (a[i] == a[i+1])) i++;
  printf("%d\n", i + 1);
  return 0;
}