1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <algorithm>
using namespace std;
int tab[2005];

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> tab[i];
    }
    sort (tab, tab+n+1);
    int l = k+1;
    while (tab[n-l+1] == tab[n-k+1] && l <= n) l++;
    cout << l-1;

    return 0;
}