#include <bits/stdc++.h>
using namespace std;
long long min(long long a, long long b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n, r;
  cin >> n >> r;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = 0;
  int last = -1;
  while (last < n - 1) {
    int pos = -1;
    for (int i = (last == -1 ? min(last + r, n - 1) : min(last + r, n - 1));
         i > max(-1, last - r + 1); --i) {
      if (a[i] == 1 && i - r <= last) {
        pos = i;
        break;
      }
    }
    if (pos == -1) {
      cout << -1 << "\n";
      return 0;
    }
    ++ans;
    last = pos + r - 1;
  }
  cout << ans << "\n";
  return 0;
}
