#include <bits/stdc++.h>
using namespace std;
int n, m, k, tmp;
long long ans;
int a[(int)(1e5 + 7)], f[(int)(1e5 + 7)];
int main() {
  scanf("%d%d", &n, &k);
  k -= 1;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  ans = (int)(1e9 + 7);
  for (int i = 1; i <= n; i++) {
    f[i] = (int)(1e9 + 7);
    if (a[i] == 0) continue;
    if (k >= i - 1) f[i] = 1;
    for (int j = i - 1; j >= 0; j--) {
      if (a[j] == 1) {
        int kc = (i - j + 1) - 2;
        if (2 * k < kc)
          j = -1;
        else
          f[i] = min(f[i], f[j] + 1);
      }
    }
    if (f[i] == (int)(1e9 + 7)) ans = -1;
    if (k >= n - i) ans = min(ans, (long long)f[i]);
  }
  if (ans == (int)(1e9 + 7)) ans = -1;
  cout << ans;
  return 0;
}
