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
31
32
33
34
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <tuple>
#include <random>
#include <cstdlib>
#include <time.h>
#include <limits>
#include <set>
#include <map>

#define INF 1000000000000000000

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(0);
    int n, k;
    std::cin >> n >> k;
    std::vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> vec[i];
        vec[i] *= -1;
    }
    std::sort(vec.begin(), vec.end());
    int boundary = vec[k - 1];
    while (k <= n && vec[k] == boundary) {
        k++;
    }
    std::cout << k;
}