#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r;
  cin >> n >> r;
  vector<int> arr(n);
  for (auto& it : arr) {
    cin >> it;
  }
  int L = 0, R = 0, cur = 0, ans = 0;
  while (L < n) {
    cur = -1;
    while (R < n && R - L < r) {
      if (arr[R++]) {
        cur = R - 1;
      }
    }
    if (cur == -1) {
      ans = -1;
      break;
    } else {
      ans++;
      L = cur + r;
    }
  }
  cout << ans << endl;
  return 0;
}
