#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, c = 0;
  scanf("%d%d", &n, &k);
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  if (a[0] != 0) {
    c = k;
    if (a[k - 1] != 0) {
      if (k != n) {
        int t = k;
        while (a[t] >= a[k - 1]) {
          c++;
          t++;
          if (t == n) break;
        }
      }
    } else {
      k = k - 1;
      while (a[k] == 0) {
        c--;
        k--;
      }
    }
    printf("%d\n", c);
  } else {
    printf("0\n");
  }
  return 0;
}
