#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323;
const double EPS = 1e-12;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
long long int a[N], pos[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, r, ct = 0;
  cin >> n >> r;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (pos[i] == 0) {
      ct++;
      long long int flag = 0;
      for (int j = i; j <= min(n, i + r - 1); j++) {
        if (a[j]) flag = j;
      }
      if (flag == 0) {
        for (int j = i; j >= max(1LL, i - r + 1); j--)
          if (a[j]) {
            flag = j;
            break;
          }
      }
      if (flag == 0) return cout << -1, 0;
      for (int j = flag; j >= max(1LL, flag - r + 1); j--) pos[j]++;
      for (int j = flag; j <= min(n, flag + r - 1); j++) pos[j]++;
    }
  }
  cout << ct;
  return 0;
}
