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 <iostream>
#include <algorithm>
using namespace std;

int tab[2009];

void task(int n, int k) {
    int ans = k;
    int i = k;
    while (tab[i] == tab[k - 1]) {
        ans++;
        i++;
    }
    cout << ans;
}

int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> tab[i];
        tab[i] *= -1;
    }
    tab[n] = 200;
    sort(tab, tab + n);
    task(n, k);
}