#include <bits/stdc++.h>
using namespace std;
int arr[2][1005];
int main(void) {
  int n, r;
  int count = 0;
  int check = 0;
  scanf("%d %d", &n, &r);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[0][i]);
    if (arr[0][i])
      for (int j = max(1, i - (r - 1)); j <= min(n, i + r - 1); j++)
        arr[1][j]++;
  }
  for (int i = 1; i <= n; i++) {
    if (arr[1][i] == 0) {
      printf("-1");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    check = 0;
    if (!arr[0][i]) continue;
    for (int j = max(1, i - (r - 1)); j <= min(n, i + r - 1); j++) {
      if (arr[1][j] == 1) {
        count++;
        check++;
        break;
      }
    }
    if (!check)
      for (int j = max(1, i - (r - 1)); j <= min(n, i + r - 1); j++)
        arr[1][j]--;
  }
  printf("%d", count);
  return 0;
}
