#include <bits/stdc++.h>
using namespace std;
bool fun(int i, int j) { return i > j; }
int main() {
  int n, k, i, temp;
  std::vector<int>::iterator up;
  vector<int> x;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> temp;
    x.push_back(temp);
  }
  while (x[k - 1] <= 0) {
    k--;
  }
  up = upper_bound(x.begin(), x.end(), x[k - 1], fun);
  cout << up - x.begin();
  return 0;
}
