#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b;
} lat[1520];
int str[1520];
int main() {
  int n, r;
  scanf("%d%d", &n, &r);
  for (int i = 0; i < n; i++) scanf("%d", &str[i]);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] == 1) {
      lat[cnt].a = i - r + 1;
      lat[cnt].b = i + r - 1;
      cnt++;
    }
  }
  int p = -1;
  int i = 0;
  int ans = 0;
  while (i < cnt) {
    int c = -1;
    while (i < cnt && lat[i].a <= p + 1) {
      c = lat[i].b;
      i++;
    }
    p = c;
    ans++;
    if (p >= n - 1) break;
    if (c == -1) break;
  }
  if (p >= n - 1)
    printf("%d\n", ans);
  else
    puts("-1");
}
