1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <cstdio>
#include <cmath>
#include <cassert>
#include <string>
#include <algorithm>
//#define DEBUG

#ifdef DEBUG
#define D(x); x
#else
#define D(x);
#endif

using namespace std;

int COMPETITORS[2001];

int main() {
  int n = 0;
  int k = 0;

  scanf("%d %d", &n, &k);

  for(int i = 0; i < n; i++) {
    scanf("%d", COMPETITORS + i);
  }

  sort(COMPETITORS, COMPETITORS + n);

  int count = 0;
  for(int i = 0; i < n; i++) {
    if(COMPETITORS[i] >= COMPETITORS[k - 1]) count++;
  }

  printf("%d\n", count);
  return 0;
}