#include <bits/stdc++.h>
const int MAXN = 1010;
int n, m;
int a[MAXN], f[MAXN];
inline int min(int a, int b) { return a < b ? a : b; }
inline int max(int a, int b) { return a > b ? a : b; }
int main() {
  scanf("%d%d", &n, &m);
  m--;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(f, 0x3f, sizeof(f));
  f[0] = 0;
  for (int i = 1; i <= n; i++)
    if (a[i])
      for (int j = max(i - m, 0); j <= i + m && j <= n; j++)
        f[j] = min(f[j], f[max(0, i - m - 1)] + 1);
  if (f[n] == 0x3f3f3f3f)
    printf("-1\n");
  else
    printf("%d\n", f[n]);
}
