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