#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6, nBits = 2e8 + 5, M = (1 << 16), MAX = 100,
          OO = 0x3f3f3f3f, MOD = 1e9, inf = 1 << 30;
const long long INF = (long long)1e18;
long long GCD(long long a, long long b) { return !b ? a : GCD(b, a % b); }
long long LCM(long long x, long long y) { return (x * y / GCD(x, y)); }
long long fact(long long z) { return (z <= 1) ? 1 : z * fact(z - 1); }
int X[] = {0, 0, 1, -1};
int Y[] = {1, -1, 0, 0};
int n, r, a[N], ans, j;
int main() {
  scanf("%d %d", &n, &r);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  --r;
  for (int i = 0, last = -1; i < n;) {
    j = min(n - 1, i + r);
    while (j > last && !a[j]) --j;
    if (j < max(0, i - r)) return puts("-1"), 0;
    ans++;
    last = j;
    i = j + r + 1;
  }
  printf("%d\n", ans);
  return 0;
}
