#include <bits/stdc++.h>
using namespace std;
int a[10010], ans;
int main() {
  int n, r, k;
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    cin >> k;
    if (k == 1)
      for (int j = i - r + 1; j <= i + r - 1; j++)
        if (j > 0) a[j] = max(a[j], i);
  }
  for (int i = 1; i <= n; i = a[i] + r) {
    if (a[i] == 0) {
      ans = -1;
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}
