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
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define rep(i,p,k) for(int i=p; i<k; i++)
#define per(i,p,k) for (int i=k-1;i>=p;i--)

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

using namespace std;

int tab[10000];

int main() {
    int n, k;
    cin >> n >> k;
    rep(i, 0, n) {
        cin >> tab[i];
    }
    sort(tab, tab+n);
    int pt = n-k-1;
    while (pt>=0 && tab[pt] == tab[pt+1])
        pt--;
    cout << n - pt-1;
}