#include <bits/stdc++.h>
using namespace std;
int conversion(string p) {
  int num;
  num = atoi(p.c_str());
  return num;
}
string toString(int h) {
  stringstream ss;
  ss << h;
  return ss.str();
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }
vector<int> V;
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = (int)0; i < (int)n; ++i) {
    int a;
    cin >> a;
    V.push_back(a);
  }
  sort((V).rbegin(), (V).rend());
  int cnt, c = 0;
  while (c < n) {
    cnt = 0;
    for (int i = c; i >= 0; --i) {
      if (V[i] >= V[c]) {
        cnt++;
      }
    }
    for (int i = c + 1; i < n; ++i) {
      if (V[i] == V[c]) cnt++;
    }
    if (cnt >= k) {
      break;
    }
    c++;
  }
  cout << V[c] << endl;
  return 0;
}
