#include using namespace std; #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) using ll = long long; using ld = long double; #define int ll #define double ld #define VARNAME(v) #v using P = pair; constexpr int MOD = 1000000007; //constexpr int MOD = 998244353; constexpr ll INF = 1e16; #pragma region tmp constexpr double EPS = 1e-10; constexpr double PI = 3.141592653589793; const string endn = "\n"; const string abc="abcdefghijklmnopqrstuvwxyz"; const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; templateostream &operator<<(ostream &out, const pair &o){out << "(" << o.first << ", " << o.second << ")";return out;} template ostream &operator<<(ostream &out, const vector &o){for(auto itr=o.begin();itr != o.end();itr++)out << *itr << (itr+1 != o.end() ? " " : "");return out;} template ostream &operator<<(ostream &out, const deque &o){for(auto itr=o.begin();itr != o.end();itr++)out << *itr << (itr+1 != o.end() ? " " : "");return out;} template ostream &operator<<(ostream &out, const set &o){out << "{";for(auto itr=o.begin();itr != o.end();itr++)out << *itr << (next(itr,1) != o.end() ? "," : "");out << "}";return out;} template ostream &operator<<(ostream &out, const multiset &o){out << "{";for(auto itr=o.begin();itr != o.end();itr++)out << *itr << (next(itr,1) != o.end() ? "," : "");out << "}";return out;} template ostream &operator<<(ostream &out, const map &o){out << "{";for(auto itr=o.begin();itr != o.end();itr++)out << *itr << (next(itr,1) != o.end() ? " " : "");out << "}";return out;} template ostream &operator<<(ostream &out, const multimap &o){out << "{";for(auto itr=o.begin();itr != o.end();itr++)out << *itr << (next(itr,1) != o.end() ? " " : "");out << "}";return out;} template ostream &operator<<(ostream &out, queue o){while(!o.empty())out << o.front() << (o.size() > 0 ? " " : ""),o.pop();return out;} template ostream &operator<<(ostream &out, priority_queue, U> o){while(!o.empty())out << o.top() << (o.size() > 0 ? " " : ""),o.pop();return out;} template ostream &operator<<(ostream &out, stack o){while(!o.empty())out << o.top() << (o.size() > 0 ? " " : ""),o.pop();return out;} template inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;} template inline bool chmax(T& a, T b){if(a inline bool chmin(T& a, initializer_list b){T c = min(b);if(a>c){a = c;return 1;}return 0;} template inline bool chmax(T& a, initializer_list b){T c = max(b);if(a b, int M=MOD){return a=(mrep(a,M)+accumulate(b.begin(), b.end(), (int)0, [&M](int acc, int i){return (acc+mrep(i,M))%M;}))%M;} inline int mul(int& a, initializer_list b, int M=MOD){return a=(mrep(a,M)*accumulate(b.begin(), b.end(), (int)1, [&M](int acc, int i){return (acc*mrep(i,M))%M;}))%M;} inline int modpow(int b, int e, int M=MOD){int ret=1;while(e > 0){if(e%2)mul(ret,b,M);mul(b,b,M);e /= 2;};return ret;} inline int modinv(int a, int M=MOD){int b=M,u=1,v=0;while(b){int t=a/b;a-=t*b;swap(a,b);u-=t*v;swap(u,v);}return mrep(u,M);} template inline void print(T a){cout << a << endl;} template inline void print(vector a, int n){chmin(n,int(a.size()));rep(i,n)cout << a[i] << (i != n-1 ? " " : "\n");} template inline void print(T (&a)[SIZE], int n=SIZE){chmin(n,int(SIZE));rep(i,n)cout << a[i] << (i != n-1 ? " ":"\n");} #pragma #endregion tmp #define vint vector class union_find{ int N;vector par; public: union_find(int N){ par.resize(N); rep(i,N)par[i] = -1; } int find(int x){ if(par[x] < 0)return x; else{ return par[x] = find(par[x]); } } void unite(int x, int y){ x = find(x); y = find(y); if(x == y)return; par[y] += par[x]; par[x] = y; } bool same(int x, int y){ return find(x) == find(y); } int size(int x){ return -par[find(x)]; } }; template struct edge { int to, from;T cost; edge(int to) : from(-1), to(to), cost(-1) {} edge(int to, T cost) : from(-1), to(to), cost(cost) {} edge(int from, int to, T cost) : from(from), to(to), cost(cost) {} }; template using edges = vector>; template using graph = vector>; template using matrix = vector>; template bool compByCost(const edge& left, const edge& right){ return left.cost < right.cost; } signed main(){ int n,k;cin>>n>>k; int p[200];rep(i,n)cin>>p[i]; for(int i = 500;i >= 0;i--){ int cnt = 0; rep(j,n)cnt += (p[j] >= i); if(cnt <= k){ cout << cnt << endl; return 0; } } }