#include <bits/stdc++.h>
using namespace std;
pair<int, int> arr[1001];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, r, aux, cont = 0, ans = 0, ant = -1, a, b;
  cin >> n >> r;
  for (int i = 0; i < n; i++) {
    cin >> aux;
    if (aux) {
      a = max(0, i - r + 1);
      b = min(n - 1, i + r - 1);
      arr[cont++] = {a, b};
    }
  }
  if (cont == 0) {
    cout << "-1\n";
    return 0;
  }
  aux = 0;
  sort(arr, arr + cont);
  while (aux < n) {
    int idx = upper_bound(arr, arr + cont, make_pair(aux, n)) - arr - 1;
    if (idx == -1 || aux == ant) {
      cout << "-1\n";
      return 0;
    }
    ant = aux;
    aux = arr[idx].second + 1;
    ans++;
  }
  cout << ans << '\n';
  return 0;
}
