#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int v = 0;
  int ans = 0, ans1 = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (i < k - 1 && a != 0) ans1++;
    if (i == k - 1) ans = a;
    if (i >= k - 1 && a == ans && ans > 0) v++;
  }
  cout << v + ans1 << "\n";
}
