#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int32_t n, k; cin >> n >> k; vector ps(n); for (auto &&p : ps) { cin >> p; } ps.push_back(numeric_limits::max()); sort(ps.rbegin(), ps.rend()); while (ps[k] == ps[k + 1]) { --k; } cout << k << endl; return 0; }