#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int man = 2e5 + 10;
int pre[man], a[man];
signed main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (pre[i]) continue;
    int l = max(1, i - k + 1);
    int r = min(n, i + k - 1);
    int tp = -1;
    for (int j = r; j >= l; j--) {
      if (a[j]) {
        tp = j;
        break;
      }
    }
    if (tp == -1) {
      ans = -1;
      break;
    } else {
      ans++;
      a[tp] = 0;
      int l = max(1, tp - k + 1);
      int r = min(n, tp + k - 1);
      for (int j = l; j <= r; ++j) pre[j]++;
    }
  }
  cout << ans << endl;
  return 0;
}
