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