1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  int n, k; cin >> n >> k;
  vector<int> V(n);
  for (auto &x:V) cin >> x;
  nth_element(V.begin(), V.begin()+k-1, V.end(), greater<int>());
  cout << count_if(V.begin(), V.end(), [&](int x) {return x>=V[k-1];}) << endl;
  return 0;
}