#include <bits/stdc++.h>
int m[1000];
int main() {
  int n, r;
  int ptr1 = -1, ptr2;
  int cnt = 0;
  scanf("%d %d", &n, &r);
  for (int i = 0; i < n; i++) scanf("%d", m + i);
  ptr2 = r - 1;
  while (ptr1 != ptr2) {
    if (m[ptr2] == 1) {
      cnt++;
      ptr1 = ptr2;
      if (ptr2 + r >= n) {
        printf("%d\n", cnt);
        return 0;
      } else if (ptr2 + 2 * r >= n) {
        ptr2 = n - 1;
      } else {
        ptr2 += 2 * r - 1;
      }
    } else {
      ptr2--;
    }
  }
  printf("-1\n");
  return 0;
}
