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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
      --------------------------------------------------
      |   made by Matvey Bunos (@nyashenotik) with <3  |
      |           2021 - Lyceum BSU - 11 IM	       	   |
      |          *** All rights reserved *** 	       |
      --------------------------------------------------
                                                        **/

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <chrono>
#include <cassert>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace __gnu_pbds;
using namespace std;

///anti hash away
const int64_t RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();

struct chash {
    int64_t operator()(int64_t x) const { return x ^ RANDOM; }
};

//to use: gp_hash_table<key, int64_t, chash> table;
typedef tree<int64_t, null_type, less<int64_t>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int64_t MAXN = 2e5 + 1;
const int64_t mod = 1e9 + 7;
const int64_t secondmod = 998244353;

int64_t binpow(int64_t a, int64_t b, int64_t mod) {
    int64_t res = 1;

    while (b) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b /= 2;
    }

    return res;
}

void slv() {
   int n, k;
   cin >> n >> k;

   vector <int> a (n);
   for(int i = 0; i < n; ++ i)
       cin >> a[i];

   sort(a.begin(), a.end());
   int i = k - 1;
   while(i > 0 && i < n && a[i] == a[i - 1])
       ++ i;

   cout << i + 1;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int64_t t = 1;
//    cin >> t;

    for (int64_t i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        slv();
        cout << '\n';
    }
    return 0;
}