#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n, k; cin >> n >> k; vector p(n); rep(i, n) cin >> p[i]; sort(p.begin(), p.end()); int ok = 1e9, ng = -1; while (ok - ng > 1) { int mid = (ok + ng) / 2; int ac = p.end() - lower_bound(p.begin(), p.end(), mid); (ac > k ? ng : ok) = mid; } cout << (p.end() - lower_bound(p.begin(), p.end(), ok)) << endl; return 0; }