#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  int n, k;
  cin >> n >> k;
  v.resize(n);
  for (int& num : v) cin >> num;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i] == 0) break;
    if (v[i] >= v[k - 1])
      ans++;
    else
      break;
  }
  cout << ans << "\n";
  return 0;
}
