#include <bits/stdc++.h>
int main() {
  int prev = -1, curr = -1, count = 0, k, n;
  std::cin >> n >> k >> curr;
  while (n-- > 0 && (k-- > 0 || curr == prev)) {
    if (curr > 0) {
      count++;
    }
    prev = curr;
    std::cin >> curr;
  }
  std::cout << count;
}
