#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
long double eps = 1e-9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, r, val;
  cin >> n >> r;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  int index = -1, total = 0;
  bool flag = true;
  while (index < n - 1) {
    int heater = -1;
    for (int i = min(index + r, n - 1); i > max(-1, index - r + 1); i--) {
      if (v[i]) {
        heater = i;
        break;
      }
    }
    if (heater == -1) {
      flag = false;
      break;
    }
    total++;
    index = heater + r - 1;
  }
  if (flag)
    cout << total << '\n';
  else
    cout << -1 << '\n';
}
