#include <bits/stdc++.h>
using namespace std;
int a[1024], dp[1024][1024], n, w;
int f(int i, int p) {
  if (p >= n) return 0;
  if (i == n) return 1e9;
  if (dp[i][p] != -1) return dp[i][p];
  int r = f(i + 1, p);
  if (a[i] && i - w < p) r = min(r, 1 + f(i + 1, i + w));
  return dp[i][p] = r;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> w;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) cin >> a[i];
  memset(dp, -1, sizeof dp);
  int r = f(0, 0);
  if (r == 1e9) r = -1;
  cout << r << "\n";
}
