#include <bits/stdc++.h>
using namespace std;
void method(string a, string b) {
  if (a.size() < b.size()) method(b, a);
  string c = b;
  for (int i = 0; i < b.size(); i++) {
    if (b[b.size() - i - 1] == '1' && a[a.size() - i - 1] == '1')
      c[c.size() - i - 1] = '1';
    else
      c[c.size() - i - 1] = '0';
  }
}
int main() {
  int n, r;
  cin >> n >> r;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int i = 0;
  int cur = 0;
  int mx = 0;
  int b[n];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    b[i] = 0;
  }
  for (i = 0; i < n; i++) {
    if (b[i] == 0) {
      bool found = false;
      int k = i + r - 1;
      for (int j = min(k, n - 1); j >= max(i - r + 1, 0); j--) {
        if (a[j] == 1) {
          found = true;
          ans++;
          for (int c = j - r + 1; c <= min(j + r - 1, n - 1); c++) {
            b[c] = 1;
          }
          break;
        }
      }
      if (!found) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}
