#include <bits/stdc++.h>
using namespace std;
int main() {
  int s = 1, x = 0, i, j, n, ww, v[10001], d[10001];
  cin >> n;
  cin >> ww;
  for (i = 1; i <= n; i++) cin >> v[i];
  for (j = 1; j <= n; j++) {
    int max = 40000;
    for (i = 1; i <= n; i++)
      if (v[i] < max and v[i] > 0) {
        max = v[i];
        x = i;
      }
    v[x] = -1;
    d[j] = max;
  }
  cout << d[n - ww + 1];
}
