#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 10;
int a[N];
int n, r;
int main() {
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int last = 0, ans = 0;
  while (last < n) {
    bool flag = false;
    for (int i = min(n, last + r); i > max(0, last - r + 1); i--) {
      if (a[i] == 1) {
        ans++;
        flag = true;
        last = min(n, i + r - 1);
        break;
      }
    }
    if (!flag) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}
