#include <bits/stdc++.h>
using namespace std;
int arr[1050], pos;
int n_l, n_r;
int main() {
  int n, r;
  scanf("%d%d", &n, &r);
  --r;
  for (int i = 1, c; i <= n; ++i) {
    scanf("%d", &c);
    if (c == 1) {
      arr[pos++] = i;
    }
  }
  n_l = 1001;
  n_r = 0;
  int ans = 0;
  if (pos == 0) {
    printf("-1\n");
    return 0;
  }
  while (n_r < n) {
    int max_f = 0, b_ans = -1;
    for (int j = 0; j < pos; ++j) {
      if (arr[j] + r > n_r && arr[j] - r <= n_r + 1 &&
          min(n_l, arr[j] - r) <= 1) {
        n_l = min(n_l, arr[j] - r);
        int hh = r + 1 + min(r, arr[j] - (1 + n_r));
        if (hh > max_f) {
          max_f = hh;
          b_ans = j;
        }
      }
    }
    if (b_ans != -1) {
      n_r = min(n, arr[b_ans] + r);
      ans++;
    } else {
      printf("-1\n");
      return 0;
    }
  }
  printf("%d\n", ans);
  return 0;
}
