#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int maxn = 1002;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, r;
  cin >> n >> r;
  long long arr[n];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  r--;
  long long todo = 0, count = 0;
  while (todo < n) {
    long long start = todo - r;
    if (start < 0) start = 0;
    int last = -1;
    while (start <= todo + r && start < n) {
      if (arr[start] == 1) last = start;
      start++;
    }
    if (last == -1) {
      cout << -1;
      return 0;
    }
    count++;
    todo = last + r + 1;
  }
  cout << count;
  return 0;
}
