#include <bits/stdc++.h>
using namespace std;
const int maxn = 1001;
int a[maxn];
int n, r;
void nhap() {
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
}
void xuli() {
  int l = 1;
  int i = 0;
  while (l <= r) {
    if (a[l] == 1) i = l;
    l++;
  }
  if (i == 0) {
    cout << -1;
    return;
  }
  l = i;
  int res = 1;
  while (l < n - r + 1) {
    int cs = 0;
    for (int i = l + 1; i < min(l + r * 2, n + 1); i++) {
      if (a[i] == 1) {
        cs = i;
      }
    }
    if (cs == 0) {
      cout << -1;
      return;
    }
    l = cs;
    res++;
  }
  cout << res;
}
int main() {
  nhap();
  xuli();
}
