#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, r, a[10000], t = 0;
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == 1) t = 1;
  }
  if (t == 0) {
    cout << -1;
    return 0;
  }
  int x = r, pros = 0, ans = 0;
  while (x - r + 1 <= n) {
    while (a[x] != 1 && x > pros) x--;
    if (x == pros) {
      cout << -1;
      return 0;
    }
    pros = x;
    ans++;
    x += 2 * r - 1;
  }
  cout << ans;
}
