#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000010;
int a[MAXN];
int main() {
  int n, r;
  while (~scanf("%d %d", &n, &r)) {
    int k;
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &k);
      if (k == 1) {
        for (int j = max(1, i - r + 1); j <= min(n, i + r - 1); j++) {
          a[j] = max(a[j], i);
        }
      }
    }
    int i = 1, ans = 0;
    bool flag = false;
    while (i <= n) {
      if (a[i] == 0) {
        printf("-1\n");
        flag = true;
        break;
      }
      ans++;
      i = a[i] + r;
    }
    if (!flag) printf("%d\n", ans);
  }
  return 0;
}
