#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r;
  cin >> n >> r;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<int> heaters;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 1) heaters.push_back(i);
  }
  vector<int> hcei[n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < heaters.size(); j++) {
      if (abs(heaters[j] - i) < r) {
        hcei[i].push_back(heaters[j]);
      }
    }
  }
  set<int> usedheaters;
  for (int i = 0; i < n; i++) {
    if (hcei[i].size() == 0) {
      cout << -1;
      return 0;
    }
    int latestcaseofnotcoveredyet = hcei[i][hcei[i].size() - 1];
    bool y = true;
    for (int j = 0; j < hcei[i].size(); j++) {
      if (usedheaters.find(hcei[i][j]) != usedheaters.end()) {
        y = false;
        break;
      }
    }
    if (y) usedheaters.insert(latestcaseofnotcoveredyet);
  }
  cout << usedheaters.size() << endl;
}
