#include <bits/stdc++.h>
using namespace std;
int a[1010];
int main() {
  int n, r, ans = 0, t = 0;
  cin >> n >> r;
  for (int i = 0; i < n; i++) cin >> a[i];
  while (t < n) {
    int idx = -1;
    for (int i = 0; i < n; i++)
      if (a[i])
        if (i - r + 1 <= t && i + r - 1 >= t) idx = i;
    if (idx == -1) {
      cout << "-1" << endl;
      return 0;
    }
    ans++;
    t = idx + r;
  }
  cout << ans << endl;
  return 0;
}
