#include <bits/stdc++.h>
const int maxn = 1000;
using namespace std;
int a[maxn + 5], n, r, last, res;
int main(void) {
  cin >> n >> r;
  for (int i = 1; i <= n; i++) cin >> a[i];
  while (last < n) {
    int pos = 0;
    for (int i = n; i > max(0, last - (r - 1)); i--)
      if (a[i] && i - r <= last) {
        pos = i;
        break;
      }
    if (!pos) {
      cout << "-1" << endl;
      return 0;
    }
    res++;
    last = pos + r - 1;
  }
  cout << res << endl;
  return 0;
}
