#include<bits/stdc++.h> using namespace std; int main(){ int n, x; cin >> n >> x; vector<int> arr; for(int i = 0; i < n; i++){ int temp; cin >> temp; arr.push_back(temp); } sort(arr.begin(), arr.end(), greater<int>()); int count = 0; int j = x - 1; if(arr[j] != 0){ while(j + 1 < n && arr[j] == arr[j + 1]){ count++; j++; } } else{ count--; while(j - 1 >= 0 && arr[j] == arr[j - 1]){ count--; j--; } } cout<<x + count<<endl; return 0; }