#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ll long long
int main(){
IOS
int n,k;cin>>n>>k;
vector<int>v(n);
for(int i = 0;i<n;i++)
cin>>v[i];
sort(v.begin(),v.end());
unordered_map<int,int>mp;
int ans=v[k-1];
for(int i = k-1;i>0;i--)
if(v[i]==v[i-1])
mp[v[i]]++;
for(auto it:mp)
ans+=it.second;
cout<<ans;
}