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
#include<bits/stdc++.h>
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;
 
const ll  INF = 1e9 + 9;
const ll  MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n,k; cin >> n >> k;
    vector<int> tab;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        tab.push_back(x);
    }
    sort(tab.rbegin(),tab.rend());
	int val = tab[k-1];
    int ile = 0;
    for(int i = 0; i < n; i++) if(tab[i] >= val) ile++;
    cout << ile << "\n";
	return 0;
}