#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const double Pi = acos(-1.0);
const long long MOD = 998244353;
int a[1005];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int pos;
  bool flag = false;
  for (int i = k; i >= 1; --i)
    if (a[i] == 1) {
      pos = i + k;
      flag = true;
      break;
    }
  if (flag == false) {
    printf("-1\n");
    return 0;
  }
  int ans = 1;
  while (pos <= n) {
    flag = false;
    for (int i = min(pos + k - 1, n); i >= 1 && i >= pos - k + 1; --i) {
      if (a[i] == 1) {
        pos = i + k;
        ++ans;
        flag = true;
        break;
      }
    }
    if (flag == false) break;
  }
  if (flag == false)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}
