#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r;
  cin >> n >> r;
  int a[n];
  int last = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1) last = i;
  }
  int x = -1, i = 0;
  while (i < r && i < n) {
    if (a[i] == 1) x = i;
    i++;
  }
  if (x == -1) {
    cout << -1;
    return 0;
  }
  if (last + r < n) {
    cout << -1;
    return 0;
  }
  int count = 1;
  i = x;
  int y = x;
  while (i < n) {
    while (i < x + 2 * r && i < n) {
      if (a[i] == 0)
        i++;
      else {
        y = i;
        i++;
      }
    }
    if (x + r >= n)
      break;
    else if (y > x) {
      x = y;
      count++;
    } else {
      cout << -1;
      return 0;
    }
  }
  cout << count;
}
