#include <bits/stdc++.h>
using namespace std;
const int kMax = 1010;
int n, r;
int a[kMax];
int solve() {
  vector<int> h;
  for (int i = 0; i < n; ++i) {
    if (a[i]) h.emplace_back(i);
  }
  int res = 0, l = -1;
  for (int i = 0; i < n; ++i) {
    if (i > l) {
      int j = lower_bound(h.begin(), h.end(), i - r + 1) - h.begin();
      if (j == h.size() || h[j] > i + r - 1) return -1;
      while (j < (int)h.size() && h[j] <= i + r - 1) ++j;
      ++res;
      l = h[j - 1] + r - 1;
    }
  }
  return res;
}
int main() {
  ;
  scanf("%d%d", &n, &r);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  printf("%d\n", solve());
  return 0;
}
