#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long gcdf(long long a, long long b) {
  while (a != 0 && b != 0) {
    if (a > b) {
      a %= b;
    } else {
      b %= a;
    }
  }
  return max(a, b);
}
long long power(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
long long mod_div(long long a, long long b) { return power(a, b - 2, b) % MOD; }
int id[100001];
int wt[100001];
int root(int i) {
  while (i != id[i]) i = id[i];
  return i;
}
void uni(int x, int y) {
  int a = root(x);
  int b = root(y);
  if (a == b) return;
  if (wt[a] > wt[b]) {
    wt[a] += wt[b];
    id[b] = id[a];
  } else {
    wt[b] += wt[a];
    id[a] = id[b];
  }
  return;
}
int main() {
  long long test = 1, i, j;
  while (test--) {
    int n, k;
    cin >> n >> k;
    int last = -1, cover = 0;
    vector<int> v;
    for (i = 0; i < n; i++) {
      int x;
      cin >> x;
      if (x) v.push_back(i + 1);
    }
    int ans = 0;
    for (i = 0; i < v.size(); i++) {
      if (cover >= n) break;
      int left = max(v[i] - k + 1, 1);
      int right = min(v[i] + k - 1, n);
      if (left > cover + 1) {
        if (last == -1) {
          cout << -1 << endl;
          return 0;
        } else {
          ans++;
          cover = last + k - 1;
          last = -1;
          i--;
          continue;
        }
      }
      last = v[i];
    }
    if (last != -1 && cover < n) {
      ans++;
      int left = max(last - k + 1, 1);
      int right = min(last + k - 1, n);
      if (left > cover + 1) {
        cout << -1 << endl;
        return 0;
      }
      cover = right;
    }
    if (cover >= n)
      cout << ans << endl;
    else
      cout << -1 << endl;
  }
}
