#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e3 + 5;
long long n, r, t, vis[MAXN];
bool cmp(const pair<long long, long long>& a,
         const pair<long long, long long>& b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second > b.second;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  while (cin >> n >> r) {
    memset(vis, 0, sizeof(vis));
    vector<pair<long long, long long>> v;
    for (int i = 1; i <= n && cin >> t; ++i)
      if (t)
        v.emplace_back(max(i - r + 1, 1LL), min(n, i + r - 1)),
            vis[max(i - r + 1, 1LL)] = 1;
    sort(v.begin(), v.end(), cmp);
    if (v.empty() || !v.empty() && v[0].first != 1)
      cout << -1 << endl;
    else {
      bool flag = true;
      long long ans = 1;
      pair<long long, long long> mx(-1, -1), p(v[0]);
      for (int i = 1; i < (signed)v.size() && flag; ++i) {
        if (v[i].first <= p.second + 1) {
          if (mx.first < v[i].first) mx = v[i];
        } else {
          ans++;
          if (~mx.first)
            p = mx, mx = make_pair(-1, -1), i--;
          else
            flag = false;
        }
      }
      if (p.second != n && flag) {
        if (mx.second == n)
          ans++;
        else
          flag = false;
      }
      cout << (flag ? ans : -1) << endl;
    }
  }
}
