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

int K[2001];

int main()
{
    int n, k;
    cin >> n >> k;
    
    int T[n];
    
    for (int i = 0; i < n; i++) {
        cin >> T[i];
        K[T[i]]++;
    }
        
    sort (T, T + n, greater <int>());
    
    int i = 0;
    while (T[i] != T[k-1]) i++;
    
    cout << i + K[T[k-1]];

    return 0;
}