#include <bits/stdc++.h>
using namespace std;
int a[55], n, k;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int r = k + 1;
  while (a[r] == a[k] && r <= n) ++r;
  --r;
  while (a[r] <= 0 && r > 0) --r;
  cout << r << endl;
}
