#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int a[maxn];
int main() {
  int n, r;
  cin >> n >> r;
  for (int i = 0; i < n; i++) cin >> a[i];
  int t = 0;
  int cnt = 0;
  int ok = 0;
  while (t < n) {
    ok = -1;
    for (int i = 0; i < n; i++)
      if (a[i])
        if (i - r < t && i + r > t) {
          ok = i;
        }
    if (ok == -1) {
      cout << "-1" << endl;
      return 0;
    }
    t = ok + r;
    cnt++;
  }
  if (ok >= 0) cout << cnt << endl;
}
