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