#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const int N = 1e6;
int T, n, r, A[1005];
void solve() {
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  int ans = 0;
  int z;
  for (int i = 1; i <= n; i = z + r) {
    bool can_warm = false;
    z = -1;
    int left = max(i - r + 1, 0), right = min(i + r, n + 1);
    for (int j = left; j < right; j++) {
      if (A[j]) {
        can_warm = true;
        z = j;
      }
    }
    if (!can_warm) {
      cout << -1;
      return;
    }
    ans++;
  }
  cout << ans;
}
int(main)() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  T = 1;
  while (T--) {
    solve();
  }
}
