#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, r;
  cin >> n >> r;
  vector<int> a(4000, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int last = 0;
  int res = 0;
  for (int i = r; i - r < n; i--) {
    if (last == i) {
      cout << -1;
      return 0;
    }
    if (a[i] == 1) {
      last = i;
      res++;
      i += 2 * r;
    }
  }
  cout << res;
  return 0;
}
