#include <bits/stdc++.h>
using namespace std;
long long sigma(long long n) { return (n * (n + 1) / 2); }
long long MOD(long long x) {
  if (x >= 0) return x;
  return (-x);
}
bool great(long long a, long long b) { return a > b; }
bool p_sm(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first == b.first) {
    return (a.second < b.second);
  }
  return (a.first < b.first);
}
long long max3(long long a, long long b, long long c) {
  return (max(a, max(b, c)));
}
long long max4(long long a, long long b, long long c, long long d) {
  return (max(max(a, b), max(c, d)));
}
long long min3(long long a, long long b, long long c) {
  return (min(a, min(b, c)));
}
long long min4(long long a, long long b, long long c, long long d) {
  return (min(min(a, b), min(c, d)));
}
vector<long long> factors(long long x) {
  vector<long long> v;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      v.push_back(i);
      if (i != x / i) {
        v.push_back(x / i);
      }
    }
  }
  return v;
}
long long min_prime[1000006];
bool ispr[1000006];
void strt() {
  for (int i = 0; i < 1000005; i++) {
    min_prime[i] = -1;
  };
  for (int i = 0; i < 1000005; i++) {
    ispr[i] = true;
  };
  for (long long i = 2; i * i <= 1000005; i++) {
    if (!ispr[i]) {
      continue;
    }
    for (long long j = i * i; j <= 1000005; j += i) {
      if (min_prime[j] == -1) min_prime[j] = i;
      ispr[j] = false;
    }
  }
  for (long long i = 2; i < 1000006; i++) {
    if (ispr[i]) {
      min_prime[i] = i;
    }
  }
}
map<long long, long long> prime_fact(long long x) {
  map<long long, long long> mp;
  while (x != 1) {
    mp[min_prime[x]]++;
    x /= min_prime[x];
  }
  return mp;
}
long long power(long long a, long long b, long long m) {
  long long ans = 1;
  while (b > 0) {
    if (b % 2) {
      ans = (ans * a) % m;
    }
    a = (a * a) % m;
    b = b / 2;
  }
  return ans;
}
vector<int> prefix_function(string s) {
  int n = (int)s.length();
  vector<int> pi(n);
  for (int i = 1; i < n; i++) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) j++;
    pi[i] = j;
  }
  return pi;
}
int main() {
  long long n, r;
  cin >> n >> r;
  vector<pair<long long, long long> > a;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (x) {
      a.push_back(make_pair(max(0LL, (i - r + 1)), min((i + r - 1), n - 1)));
    }
  }
  if (a.size() == 0) {
    cout << -1 << endl;
    exit(0);
    ;
  }
  sort(a.begin(), a.end(), p_sm);
  long long i = 0;
  long long ans = 0;
  for (long long j = 0; j < a.size(); j++) {
    if (a[j].first > 0) break;
    i = j;
  }
  if (a[0].first != 0 || a[a.size() - 1].second != n - 1) {
    cout << -1 << endl;
    exit(0);
    ;
  }
  while (i < a.size()) {
    long long j = i;
    ans++;
    if (a[i].second == n - 1) {
      cout << ans << endl;
      exit(0);
      ;
    }
    while (a[j].first < a[i].second + 2) {
      j++;
      if (j == a.size()) {
        break;
      }
    }
    if (j < a.size()) {
      if (j == (i + 1)) {
        cout << -1 << endl;
        exit(0);
        ;
      }
    }
    i = j - 1;
  }
}
