#include <bits/stdc++.h>
int vVelPC[32770];
void internet(int cantPart);
int main() {
  int cantComp, cantPart, velComp;
  scanf("%d%d", &cantComp, &cantPart);
  while (cantComp--) {
    scanf("%d", &velComp);
    vVelPC[velComp]++;
  }
  internet(cantPart);
  return 0;
}
void internet(int cantPart) {
  for (int i = 32770; i >= 0; --i) {
    cantPart -= vVelPC[i];
    if (cantPart <= 0) {
      printf("%d", i);
      break;
    }
  }
}
