#include <bits/stdc++.h>
using namespace std;
long long a[200009];
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long i, n, r, l = 0, c = 0;
  cin >> n >> r;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n;) {
    long long n = i + r - 1, k = 0;
    while (n > l) {
      if (a[n]) {
        k = n;
        break;
      }
      n--;
    }
    if (!k) {
      cout << -1;
      return 0;
    }
    l = i;
    i = k + r, c++;
  }
  cout << c;
}
