#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
  int n, m;
  while (cin >> n >> m) {
    v.clear();
    for (int i = 1; i <= n; i++) {
      int f;
      cin >> f;
      if (f) v.push_back(i);
    }
    int ed = 0;
    int ans = 0;
    while (ed < n) {
      int r = 0;
      for (int i = 0; i < v.size(); i++) {
        if (v[i] - m + 1 <= ed + 1) {
          r = max(r, v[i] + m - 1 - ed);
        }
      }
      if (!r) {
        ans = 0;
        break;
      } else {
        ed += r;
        ans++;
      }
    }
    if (ans)
      cout << ans << endl;
    else
      cout << "-1" << endl;
  }
}
