#include<bits/stdc++.h>
using namespace std;
int main(){
long long k, n, s, counter = 0, extra = 0;
cin >> n >> k;
vector<int> v;
for(int i = 0; i < n; i++){
cin >> s;
v.push_back(s);
}
sort(v.begin(), v.end());
for(int i =1; i < n; i++){
if(v[i] == v[i-1])
counter++;
}
for(int i =k-1; i >=0; i--){
if(v[i] - v[i-1] == 0 && v[k-1] <= v[i])
extra++;
}
cout << v[k-1] + extra;
}