#include <bits/stdc++.h>
using namespace std;
const int N = 200;
int n, a[N], k;
bool ok(int x) {
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i] >= x) ans++;
  }
  return (ans >= k);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = n; i > 0; --i) {
    if (ok(a[i])) {
      cout << a[i];
      return 0;
    }
  }
  return 0;
}
