#include using namespace std; typedef long long ll; int main() { int n, k; cin >> n >> k; int maxv = 0; int p[n]; for (int i = 0; i < n; i++) { cin >> p[i]; maxv = max(maxv, p[i]); } for (int b = 0; b < maxv; b++) { int cnt = 0; for (int i = 0; i < n; i++) { cnt += b <= p[i]; } if (cnt <= k) { cout << cnt << endl; return 0; } } cout << 0 << endl; return 0; }