#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
long long int func(long long int num) {
  long long int n, r;
  cin >> n >> r;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int i = 0, cnt = 0, lasti = -10000;
  while (i < n) {
    long long int j = min(n - 1, i + r - 1);
    long long int f = 0;
    while (j > lasti) {
      if (j < 0 or j >= n) return -1;
      if (a[j] == 1) {
        cnt++;
        lasti = i;
        i = j + r;
        f = 1;
        break;
      }
      j--;
    }
    if (f == 0) {
      return -1;
    }
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t = 1;
  for (long long int num = 1; num <= t; num++) {
    cout << func(num) << endl;
  }
}
