#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e3 + 5;
const int inf = 1e9;
int n, dp[maxn][maxn], v[maxn], r, m, k, x, at, best;
long long solve2(int i, int lastaq) {
  if (abs(i - lastaq) > r) return inf;
  if (dp[i][lastaq] != -1) return dp[i][lastaq];
  if (i > n) {
    if (lastaq >= n)
      return 0;
    else
      return inf;
  }
  long long fop = solve2(i + 1, lastaq);
  long long sop = inf;
  if (v[i]) sop = solve2(i + 1, i + r - 1) + 1;
  return dp[i][lastaq] = min(fop, sop);
}
void solve() {
  cin >> n >> r;
  for (int i = 1; i <= n; i++) cin >> v[i];
  memset(dp, -1, sizeof dp);
  long long ans = inf;
  ans = solve2(1, 0);
  if (ans == inf) ans = -1;
  cout << ans << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  t = 1;
  while (t--) solve();
}
