#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, test, ind;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  reverse(a, a + n);
  test = a[k - 1];
  if (test > 0) {
    ind = -1;
    while (test == a[k + ind]) ind++;
  } else {
    ind = -1;
    while (a[k + ind] <= 0) ind--;
    ind++;
  }
  cout << k + ind;
  return 0;
}
