#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
int solve() {
  int n, r;
  cin >> n >> r;
  vector<int> a(n);
  for (int(i) = 0; (i) < (int)(n); ++(i)) cin >> a[i];
  vector<bool> warm(n);
  int ans = 0;
  for (int(i) = 0; (i) < (int)(n); ++(i))
    if (!warm[i]) {
      int pos = min(i + r - 1, n - 1);
      int s = pos;
      while (s >= 0) {
        if (a[s]) break;
        --s;
      }
      if (s == -1) return -1;
      int L = max(0, s - r + 1);
      int R = min(n - 1, s + r - 1);
      for (int j = L; j <= R; ++j) warm[j] = true;
      if (!warm[i]) return -1;
      ++ans;
    }
  return ans;
}
int main() {
  cout << solve() << endl;
  return 0;
}
