#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r, p, sum;
  int a[1000];
  bool b;
  cin >> n >> r;
  sum = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  b = false;
  for (int i = r - 1; i >= 0; i--)
    if (a[i] == 1) {
      sum++;
      p = i;
      b = true;
      break;
    }
  if (!b) {
    cout << -1;
    exit(0);
  }
  while (p + r - 1 < n - 1) {
    b = false;
    if (p + 2 * r - 1 < n - 1) {
      for (int i = p + 2 * r - 1; i > p; i--)
        if (a[i] == 1) {
          sum++;
          p = i;
          b = true;
          break;
        }
    } else {
      for (int i = n - 1; i > p; i--)
        if (a[i] == 1) {
          sum++;
          p = i;
          b = true;
          break;
        }
    }
    if (!b) {
      cout << -1;
      exit(0);
    }
  }
  cout << sum;
  return 0;
}
