#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int r;
  cin >> n >> r;
  int arr[n], pos[n];
  int m = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 1) {
      pos[m] = i;
      m++;
    }
  }
  int f[m][n];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      f[i][j] = INT_MAX - n;
    }
  }
  for (int i = 0; i < m; i++) {
    if (pos[i] - r + 1 <= 0)
      f[i][0] = 1;
    else
      f[i][0] = INT_MAX - n;
  }
  for (int j = 0; j < n; j++) {
    if (pos[0] + r - 1 >= j && pos[0] - r + 1 <= j)
      f[0][j] = 1;
    else
      f[0][j] = INT_MAX - n;
  }
  for (int i = 1; i < m; i++) {
    for (int j = 1; j < n; j++) {
      if (pos[i] + r - 1 >= j && pos[i] - r + 1 <= j) {
        if (pos[i] - r < 0)
          f[i][j] = 1;
        else
          f[i][j] = min(1 + f[i - 1][pos[i] - r], f[i - 1][j]);
      } else
        f[i][j] = INT_MAX - n;
    }
  }
  if (m == 0 || f[m - 1][n - 1] >= INT_MAX - n || f[0][0] != 1) {
    cout << -1 << endl;
    return 0;
  }
  cout << f[m - 1][n - 1] << endl;
}
