#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double eps = (1e-6);
int dcmp(double x, double y) { return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1; }
int n, r;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> r;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    bool ok = 0;
    for (int j = min((int)(a).size() - 1, i + r - 1); j >= max(i - r + 1, 0);
         --j) {
      if (a[j] == 1) {
        i = j + r - 1;
        ok = 1;
        ans++;
        break;
      }
    }
    if (!ok) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << ans << '\n';
  return 0;
}
