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 <bits/stdc++.h>
#define ll long long
#define newl cout << "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
const int iinf = (int) 1e9 + 111;
const long long inf = (long long) 1e18 + iinf;
const int N = 1e6 + 111;
const int B = 5;



int32_t main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    set<int> st;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        st.emplace(v[i]);
    }
    int i = 0, mx = 0;
    for(int it : st){
        i++;
        if (i == k){
            mx = it;
            break;
        }
    }
    int ans = 0;
    for(int it : v){
        if (it <= mx)
            ans++;
    }
    cout << ans;
    return 0;
}