#include<bits/stdc++.h>
using namespace std;
int freq[100001];
int main(){
int n, k, counter = 0;
cin >> n >> k;
int a[n];
for(int i = 0;i < n; i++){
cin >> a[i];
freq[a[i]]++;
}
sort(a, a+n);
cout << a[k-1] + (freq[a[k-1]] - 1) << endl;
}