#include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int n, k, ans = 0; cin >> n >> k; vector p(n); for (int i = 0; i < n; i++) cin >> p[i]; sort(p.begin(), p.end(), greater()); for (int i = k; i > 0; i--){ if (p[i] != p[i-1]){ ans = i; break; } } cout << ((ans > 0) ? ans : ((n == k) ? n : 0)) << endl; }