import java.util.;
import java.io.;
public class Main{
public static void main(String[] args)throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] nums1 = br.readLine().split(" ");
int n = Integer.parseInt(nums1[0]);
int k = Integer.parseInt(nums1[1]);
String[] nums2 = br. readLine().split(" ");
int[] nums = new int[n];
for(int i = 0;i < n;i++){
nums[i] = Integer.parseInt(nums2[i]);
}
System.out.print(quickSort(0,n - 1,k - 1,nums));
}
public static int quickSort(int left,int right,int k,int[] nums){
if(left >= right) return nums[k];
int i = left - 1;
int j = right + 1;
int target = nums[left + (right - left) / 2];
while(i < j){
do{
i++;
}while(nums[i] < target);
do{
j--;
}while(nums[j] > target);
if(i < j){
int num = nums[i];
nums[i] = nums[j];
nums[j] = num;
}
}
if(k <= j){
return quickSort(left,j,k,nums);
}else return quickSort(j + 1,right,k,nums);
}
}