#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, r;
  cin >> n >> r;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  bool vis[n];
  memset(vis, false, sizeof(vis));
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    int pos = -1;
    for (int j = min(n - 1, i + r - 1); j >= max(0, i - r + 1); j--) {
      if (v[j] == 1) {
        pos = j;
        break;
      }
    }
    if (pos == -1) {
      cout << -1 << "\n";
      return;
    }
    for (int i = max(0, pos - r + 1); i < min(n, pos + r); i++) vis[i] = true;
    ans++;
    i = pos + r - 1;
  }
  cout << ans << "\n";
}
int main() {
  solve();
  return 0;
}
