#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int a[N], v[N];
int main() {
  int n, r;
  while (~scanf("%d%d", &n, &r)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      v[i] = 0;
    }
    int k = r;
    while (k >= 0) {
      if (a[k] == 1) {
        break;
      }
      k--;
    }
    if (k <= 0) {
      printf("-1\n");
      return 0;
    }
    int ans = 1;
    bool ko = 0;
    int i, j;
    i = k;
    while (true) {
      j = i + 2 * r - 1;
      if (i + r - 1 >= n) {
        printf("%d\n", ans);
        return 0;
      }
      if (j >= n) ko = true;
      while (j >= i) {
        if (a[j] == 1) break;
        j--;
      }
      ans++;
      if (j <= i) {
        printf("-1\n");
        return 0;
      }
      if (ko) {
        if (n - j > r - 1) {
          printf("-1\n");
          return 0;
        } else {
          printf("%d\n", ans);
          return 0;
        }
      }
      i = j;
    }
  }
}
