#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r;
  cin >> n >> r;
  int mas[n];
  for (int i = 0; i < n; i++) {
    cin >> mas[i];
  }
  int count = 0, gr = n - 1;
  for (int i = 0; i < n; i++) {
    int fl = 0;
    if (i + r - 1 > n - 1)
      gr = n - 1;
    else
      gr = i + r - 1;
    for (int j = gr; j >= i - r + 1 && j >= 0; j--) {
      if (mas[j] == 1) {
        i = j + r - 1;
        count++;
        fl = 1;
        break;
      }
    }
    if (fl == 0) {
      cout << -1;
      return 0;
    }
  }
  cout << count;
  return 0;
}
