#include <bits/stdc++.h>
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    int ant[55] = {0};
    int temp = 0;
    int count = k;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &ant[i - 1]);
      if (i == k) temp = ant[i - 1];
    }
    if (temp)
      for (int i = k + 1; i <= n; i++) {
        if (ant[i - 1] >= temp)
          count++;
        else
          break;
      }
    else
      for (int i = k; i >= 1; i--) {
        if (!ant[i - 1]) count--;
      }
    printf("%d\n", count);
  }
  return 0;
}
