#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r;
  scanf("%d %d", &n, &r);
  int ara[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &ara[i]);
  }
  int i = min(n, r) - 1;
  while (ara[i] == 0 && i > -1) {
    i--;
  }
  if (i < 0) {
    return printf("%d\n", -1), 0;
  }
  int cnt = 1;
  for (; i < n;) {
    int j = i + 2 * r - 1;
    if (j >= n) {
      if (i + r >= n) {
        break;
      }
      j = n - 1;
    }
    while (ara[j] != 1) {
      j--;
    }
    if (j == i) {
      return printf("%d\n", -1), 0;
    }
    i = j;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}
