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
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  int N = 0;
  int K = 0;

  std::cin >> N;
  std::cin >> K;

  std::vector<int> v(N);

  for (int i = 0; i < N; ++i) {
    std::cin >> v[i];
  }

  //////////////////

  std::sort(v.begin(), v.end(), std::greater<int>());

  for (int i = K; i < N; ++i) {
    if (v[i - 1] != v[i]) {
      std::cout << i << std::endl;
      return 0;
    }
  }

  std::cout << N << std::endl;
  return 0;
}