#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  map<int, int> myMap;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    myMap[a[i]]++;
  }
  int temp = a[k - 1];
  if (temp > 0) {
    int ans = 0;
    map<int, int>::iterator it;
    for (it = myMap.begin(); it != myMap.end(); it++) {
      if (it->first >= temp) {
        ans += it->second;
      }
    }
    cout << ans << endl;
  } else {
    int ans = 0;
    map<int, int>::iterator it;
    for (it = myMap.begin(); it != myMap.end(); it++) {
      if (it->first > 0) {
        ans += it->second;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
