#include <bits/stdc++.h>
using namespace std;
int n, k;
int haha[105];
int ans = 0;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &haha[i]);
    if (haha[i] == 0)
      break;
    else if (i < k)
      ans++;
    else if (haha[i] == haha[k - 1])
      ans++;
    else
      break;
  }
  printf("%d", ans);
  return 0;
}
