#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int a[N];
int n, r;
int solve() {
  int res = 0, t = 1;
  while (t <= n) {
    int idx = 0;
    for (int i = 1; i <= n; ++i) {
      if (a[i]) {
        if (t >= i - r + 1 && t <= i + r - 1) idx = i;
      }
    }
    if (idx == 0) return -1;
    ++res;
    t = idx + r;
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &r);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  printf("%d", solve());
  return 0;
}
