#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 1;
int a[MAXN], l[MAXN], r[MAXN], cnt;
int ans_ed, now_st, now_ed;
int pre_index, now_index;
int N, R;
int ans;
bool chch;
int main() {
  scanf("%d%d", &N, &R);
  bool flag = true;
  cnt = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 1) {
      flag = false;
      cnt++;
      l[cnt] = i - R + 1;
      r[cnt] = i + R - 1;
    }
  }
  if (flag)
    printf("-1\n");
  else {
    chch = false;
    ans = 0;
    ans_ed = 1;
    int k = 1;
    bool book = false;
    do {
      if (l[k] < ans_ed) {
        book = true;
        pre_index = k;
        k++;
        if (k == cnt + 1) {
          if (ans_ed < N + 1) {
            ans++;
            ans_ed = r[k - 1] + 1;
          }
        }
        continue;
      }
      if (book) {
        if (l[k] > ans_ed) {
          now_index = pre_index;
        } else
          now_index = k;
        ans++;
        ans_ed = r[now_index] + 1;
        if (now_index == pre_index) --k;
        book = false;
      } else if (l[k] > ans_ed) {
        chch = true;
        break;
      } else {
        ans++;
        ans_ed = r[k] + 1;
      }
      k++;
    } while (k <= cnt);
    if (ans_ed <= N || ans == 0) chch = true;
    if (chch)
      printf("-1\n");
    else
      printf("%d\n", ans);
  }
  return 0;
}
