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
#include <bits/stdc++.h>
using namespace std;
int n, t, k;
vector<int>v;

int main()
{
  ios_base::sync_with_stdio(0);

  cin >> t >> k;

  while (t--) {
    cin >> n;
    v.push_back(-n);
  }

  sort(v.begin(), v.end());

  int i = k - 1;
  while(i < v.size() && v[i] == v[i + 1]) {
    i++;
  }

  cout << i + 1 << endl;

  return 0;
}