#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, k = 0, i, *mas;
  cin >> n >> k;
  if (n == 0) {
    cout << "0";
    return 0;
  }
  mas = new int[n];
  for (i = 0; i < n; i++) {
    cin >> mas[i];
    if (mas[i] == 0 && i + 1 <= k) {
      cout << i;
      return 0;
    }
    if (mas[i] == 0 && i + 1 > k) break;
  }
  for (int j = k; j < i + 1; j++) {
    if (mas[j] == mas[k - 1])
      k++;
    else
      break;
  }
  cout << k;
  return 0;
}
