#include <bits/stdc++.h>
using namespace std;
long long n, b, a[1009], l, s, d;
int main() {
  cin >> n >> b;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    d = -1;
    for (int j = i, l = i; j<i + b, l> i - b; j++, l--) {
      if (a[j] == 1) d = j;
      if (a[l] == 1 and l > d) d = l;
    }
    if (d == -1) {
      cout << -1;
      return 0;
    } else {
      s++;
      i = d + b - 1;
    }
  }
  cout << s;
}
