#include <bits/stdc++.h>
int main() {
  int n, k, s = 0, i;
  scanf("%d%d", &n, &k);
  int *tab = new int[n];
  for (i = 0; i < n; ++i) scanf("%d", &tab[i]);
  int tmp = tab[k - 1];
  i = 0;
  while (tab[i] >= tmp && tab[i] != 0) {
    ++s;
    ++i;
  }
  if (s <= n)
    printf("%d", s);
  else
    printf("%d", n);
  return 0;
}
