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

using namespace std;

int k, n;
int p[2005];

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