#include <bits/stdc++.h>
using namespace std;
long long int pre[1005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long int n, r, p, q;
    cin >> n >> r;
    long long int a[1005];
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (a[i] == 1) {
        p = max(1LL, i - r + 1);
        pre[p] += 1;
        q = min(n + 1, i + r);
        pre[q] -= 1;
      }
    }
    for (int i = 1; i <= n; i++) {
      pre[i] = pre[i - 1] + pre[i];
    }
    for (int i = 1; i <= n; i++) {
      if (pre[i] < 1) {
        cout << -1;
        return 0;
      }
    }
    long long int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] == 1) {
        p = max(1LL, i - r + 1);
        q = min(n, i + r - 1);
        long long int w = 0;
        for (int j = p; j <= q; j++) {
          if (pre[j] == 1) w = 1;
        }
        if (w == 1)
          ans++;
        else {
          for (int j = p; j <= q; j++) pre[j] -= 1;
        }
      }
    }
    cout << ans;
  }
  return 0;
}
