#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r;
  cin >> n >> r;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  int i = 0;
  while (i < n) {
    int to = i + r - 1;
    if (to >= n) to = n - 1;
    bool find = false;
    while (to > i - r) {
      if (a[to] == 1) {
        find = true;
        ans++;
        i = to + r;
        break;
      }
      to--;
      if (to < 0) break;
    }
    if (!find) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}
