#include<iostream>
using namespace std;
int A[5000005];
void half_sort(int start,int end,int need)
{
if (start + 1 >= end)
{
if (A[start] > A[end]) swap(A[start] , A[end]);
return;
}
int mid = A[(start + end)/2];
int tip1 = start , tip2 = end;
while (1)
{
while (A[tip1] < mid) ++tip1;
while (A[tip2] > mid) --tip2;
if (tip1 < tip2) swap(A[tip1] , A[tip2]);
else
{
break;
}
}
if (need > tip2)
{
half_sort(tip1 , end , need);
}
else
{
half_sort(start , tip2 , need);
}
return;
}
int main()
{
int n,t;
scanf("%d %d",&n,&t);
for (int i=0;i<n;i++)
{
scanf("%d",&A[i]);
}
half_sort(0,n-1,t);
printf("%d\n",A[t]);
return 0;
}