#include <bits/stdc++.h>
using namespace std;
int scanme() {
  int n = 0;
  char c = getchar();
  while (!('0' <= c && c <= '9')) {
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    n = n * 10 + c - '0';
    c = getchar();
  }
  return n;
}
int main() {
  int n = scanme();
  int k = scanme();
  int count = 0;
  int score;
  for (int i = 1; i <= n; i++) {
    int me = scanme();
    if (me != 0) {
      if (i == k) score = me;
      if (i <= k)
        count++;
      else {
        if (score == me) count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
