#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  m--;
  int cnt = 0;
  for (int i = 0; i < n; ++i)
    if (1) {
      bool ok = 0;
      for (int j = i + m; j >= 0 && j >= i - m; --j)
        if (j >= n)
          continue;
        else if (a[j] == 1) {
          cnt++;
          i = j + m;
          ok = 1;
          break;
        }
      if (!ok) return cout << -1, 0;
    }
  cout << cnt;
  return 0;
}
