#include <bits/stdc++.h>
int n, r, p, q, c, i, x;
int main() {
  scanf("%d%d", &n, &r);
  p = q = -r;
  for (; i < n; ++i) {
    scanf("%d", &x);
    if (x) p = i;
    if (i - q > 2 * r - 2) {
      if (p == q) {
        ++i;
        break;
      }
      q = p;
      ++c;
    }
  }
  printf("%d\n", i - p > r ? -1 : i - q > r ? c + 1 : c);
}
