1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <algorithm>

using namespace std;
int dane[2000];

int main(){
    int quantity, Tshirt, result = 0;
    cin >> quantity >> Tshirt;
    for(int i = 0; i < quantity; i++)
        cin >> dane[i];
    
    sort(dane, dane + quantity, greater<int>());

    for(int k = Tshirt; k < quantity; k++){
        if(dane[k] != dane[k-1])
            break;
        result++;
    }
    cout << result + Tshirt;
}