#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
const double pi = 2 * acos(0.0);
const int N = 1005;
int arr[N];
int heated[N];
int n, r;
void heat(int pos) {
  for (int i = pos; i <= pos + r - 1 && i < n; i++) {
    heated[i] = 1;
  }
  for (int i = pos; i >= pos - r + 1 && i >= 0; i--) {
    heated[i] = 1;
  }
}
int count(int pos) {
  int res = 0;
  for (int i = pos; i <= pos + r - 1 && i < n; i++) {
    if (!heated[i]) res++;
  }
  for (int i = pos - 1; i >= pos - r + 1 && i >= 0; i--) {
    if (!heated[i]) res++;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> r;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!heated[i]) {
      int idx = -1;
      int cnt = 0;
      for (int j = i; j <= i + r - 1 && j < n; j++) {
        int temp = count(j);
        if (arr[j] && temp > cnt) {
          idx = j;
          cnt = temp;
        }
      }
      for (int j = i; j >= i - r + 1 && j >= 0; j--) {
        int temp = count(j);
        if (arr[j] && temp > cnt) {
          idx = j;
          cnt = temp;
        }
      }
      if (idx != -1) {
        heat(idx);
        ans++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (!heated[i]) return puts("-1");
  }
  cout << ans;
  return 0;
}
