#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  int arr[50], cnt = 0;
  cin >> n >> k;
  int x;
  for (int j = 0; j < n; j++) {
    cin >> x;
    arr[j] = x;
    if (arr[j] == 0) {
      cnt++;
    }
  }
  if (cnt == n) {
    cout << "0";
    return 0;
  }
  int test_value, result;
  test_value = arr[k - 1];
  if (test_value == 0) {
    test_value++;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (arr[i] >= test_value) {
      result = i + 1;
      break;
    }
  }
  cout << result;
  return 0;
}
