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
#include <bits/stdc++.h>

using namespace std;

const int M_SIZE = 2001;

int n,k;

int a[M_SIZE];

int main() {

    cin>>n>>k;

    for(size_t i=0; i<n; i++)
        cin>>a[i];

    sort(a, a+n);

    int i = n-k;

    while(i >=1 && a[i-1] == a[i]){
        k++;
        i--;
    }

    cout<<k;

    return 0;
}