from sys import stdinarr=[]while(True): n=int(stdin.readline()) if(n==-1): break arr.append(n) n=0m=int(stdin.readline())arr.sort()m*=-1print(arr[m])