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