#include <iostream>
using namespace std;
void scan_d(int &num)
{
char in;
in=getchar();
while(in<'0'||in>'9') in=getchar();
num=in-'0';
while(in=getchar(),in>='0'&&in<='9'){num*=10,num+=in-'0';}
}
int Partition(int low,int high,int *a)
{
int i=low,j=high;
int pivotkey=a[low];
while(i<j)
{
while(i<j&&a[j]>=pivotkey)j--;
a[i]=a[j];
while(i<j&&a[i]<=pivotkey)i++;
a[j]=a[i];
}
a[i]=pivotkey;
return i;
}
void QSort(int low,int high,int *a)
{
if(low<high)
{
int local=Partition(low,high,a);
QSort(low,local-1,a);
QSort(local+1,high,a);
}
}
int main()
{
int n,pos,i;
while(cin>>n>>pos)
{
int *a=new int [n];
for(i=0;i<n;i++)
scan_d(a[i]);
QSort(0,n-1,a);
cout<<a[pos-1]<<endl;
}
return 0;
}