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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int,int>;
using graph = vector<vi>;

#define FOR(name__, upper__) for (int name__ = 0; name__ < (upper__); ++name__)
#define all(x) begin(x), end(x)
#define mp make_pair
#define mt make_tuple

void go() {
    int n, k; 
    cin >> n >> k;
    
    vi A(n); for(auto &i : A) cin >>i;
    sort(all(A));
    reverse(all(A));
    
    int i = k;
    while (i < n && A[i] == A[k - 1]) i++;
    cout << i << '\n';
}

int main() {
	ios::sync_with_stdio(false); 
	cin.tie(0);
    
    go();

	return 0;
}