#include <bits/stdc++.h>
int a[55], n, k, ans;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= k; i++)
    if (a[i] != 0) ans++;
  for (int i = k + 1; i <= n; i++)
    if (a[i] == a[k] && a[i] != 0) ans++;
  return printf("%d\n", ans), 0;
}
