#include<bits/stdc++.h>
using namespace std;
int main(){
long long k, n, s, counter = 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++;
}
//cout << counter << endl;
cout << v[k-1] + counter;
}