#include <bits/stdc++.h>
using namespace std;
void Run() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int a[200000], b[200000], res;
int main() {
  Run();
  int n, r;
  cin >> n >> r;
  for (int pos = 0; pos < n; pos++) cin >> a[pos];
  for (int pos = 0; pos < n; pos++) {
    if (b[pos] == 1) continue;
    res++;
    int cnt = -1;
    int x = max(pos - r + 1, 0);
    int y = min(pos + r - 1, n - 1);
    for (int i = y; i >= x; i--) {
      if (a[i] == 1) {
        cnt = i;
        break;
      }
    }
    if (cnt == -1) {
      cout << -1;
      return 0;
    }
    x = max(cnt - r + 1, 0);
    y = min(cnt + r - 1, n - 1);
    for (int i = y; i >= x; i--) b[i] = 1;
  }
  cout << res;
}
