#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<queue>
using namespace std;

const int oo=9999;

int n,d;
string s;

queue<int> q;
int f[210];
int mark[210]={0};

int main()
{
	cin>>n>>d;
	cin>>s;
	for(int i=2;i<=n;++i)
		f[i]=oo;
	f[1]=0;
	mark[1]=true;
	q.push(1);
	while(!q.empty())
	{
		int p=q.front();
		q.pop();
		mark[p]=false;
		for(int i=1;i<=d;++i)
		{
			int to=p+i;
			if(s[to-1]=='0')
				continue;
			if(f[to]>f[p]+1)
			{
				f[to]=f[p]+1;
				if(!mark[to])
				{
					mark[to]=true;
					q.push(to);
				}
			}
		}
	}
	if(f[n]==oo)
		cout<<-1;
	else
		cout<<f[n];
	return 0;
}

#include<iostream>
#include<string>
using namespace std;
int n, d;
string in;
int main()
{
	cin >> n >> d;
	cin >> in;
	int i = 0;
	int ans = 0;
	while (i < n-1)
	{
		bool flag = false;
		int cur = 0;
		for (int j = 1; j <= d; j++)
		{
			if (i + j >= n)
				break;
			if (in[i + j] == '1')
			{
				flag = true;
				cur = i + j;
			}
		}
		if (!flag)
		{
			ans = -1;
			break;
		}
		ans++;
		i = cur;
	}
	cout << ans;
	return 0;
}

#include <iostream>
#include<queue>
#include<string>

using namespace std;

int main()
{
    int n, d;
    cin>>n>>d;
    string way;
    cin>>way;
    vector<int> moves(n,0);
    moves[0] = 0;
    for(int i=0;i<n;i++){
        if((way[i]!='0'&&moves[i]!=0&&i>0)||i==0){
        for(int j=i+1;j<=i+d && j<n;j++){
            if(way[j] == '0')
                continue;
            else if(j == n-1 && moves[n-1] != 0)
                moves[n-1] = min(moves[n-1], moves[i]+1);
            else if(j == n-1 && moves[n-1] == 0)
                moves[n-1] = moves[i] + 1;
            else if(way[j] == '1' && moves[j] != 0)
                moves[j] = min(moves[j], moves[i]+1);
            else if(way[j] == '1')
                moves[j] = moves[i]+1;
        }
        }
    }
    if(moves[n-1] == 0)
        cout<<-1<<endl;
    else
        cout<<moves[n-1]<<endl;
    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef int ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 2e5 + 1, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, d, c, f, visited[100];
string s;
vll q = {0}, t;

//<<-----Implement Functions Here---->>//
void solve()
{
	in(n >> d >> s)
	visited[0] = 1, c = 1, f = n - 1;
	while(true)
	{
		FORALL(it, q)
			FOR(i, it + 1, min(it + d + 1, n))
				if (!visited[i] && s[i] == '1')
				{
					if (i == f)
					{
						out(c)
						return;
					}
					t.push_back(i), visited[i] = 1;
				}
		if (t.empty())
		{
			out(-1)
			return;
		}
		q = t;
		t = {};
		++c;
	}
}

//<<----------Start of Main---------->>//
int main()
{
	fastio
    //ts
    solve();
    return 0;
}

#include <iostream>

using namespace std;

int main()
{ int nbmin, l, r,i,j,n,d;
string s;
    cin >> n;
    cin>> d ;
     cin>> s  ;
    /* i=d;
    while  (i<= n)
        {if (s[i]==1)
        {
            i=j*d;
             j++ ;
        cout<< j ;
        }
        else
           cout<< (-1) ;
    }*/

    nbmin = l = r = 0;
    for (int i = 0; i < n-1; ) {
        for(int j = 1; j <= d; ++j) {
            if (s[j+i] == '1') {
                r = max (r, j+i);
            }
        }
        if (l == r) {
            cout<<("-1");
return (0) ;
        }
        l = i = r;
        ++nbmin;
    }
    cout << nbmin ;
        return(0);
    }

#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<cstring>
#include<ctime>
#include<cmath>
#include<iterator>
#include<functional>
#include<stack>

#define ll long long int
#define ind it->second
#define INF 2e9
#define llINF 2e18
#pragma comment(linker, "/STACK:268435456")
#pragma warning(disable : 4996)
using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, d;
	cin >> n >> d;
	string a;
	cin >>a;
	int res = 0;
	for (int i = 0; i < a.length();) {
		if (i == a.length() - 1) break;
		int latest = i;
		for (int j = i + 1; j < a.length()&&j - i <= d; j++) {
			if (a[j] == '1') {
				latest = j;
				//break;
			}
		}
		if (i == latest) {
			cout << -1;
			return 0;
		}
		else { res++; i = latest; }
	}
	cout << res;
}

#include<bits/stdc++.h>

using namespace std;

int main(){

	int casilla,saltos;

	cin>> casilla>> saltos;

	string x;

	cin>>x;

	int v[casilla];
	vector<bool> llego(casilla,false);

	for(int i = 0;i<casilla;i++){
		 v[i] = x[i]-'0';
	}
	queue<int> c;

	int pasos = 0;

	c.push(0);

	while(!c.empty()){

		int aux = c.front();
		c.pop();
		for(int i = saltos;i>0;i--){
			if(v[aux+i] == 1 and aux+i < casilla){
				pasos++;
				c.push(aux+i);
				llego[i+aux] = true;
				break;

			}

		}

	}
	if(llego[casilla-1]) cout<<pasos<<endl;
	else cout<<"-1"<<endl;

	return 0;
}

#include<iostream>
using namespace std;
int main(){
	int n,d;
	int ans=0;
	cin>>n>>d;
	char shu[1000];
	cin>>shu;
	for(int i=0;i<n-1;){
		int flag=0;
		for(int j=i+1;j<=i+d && j<n;j++){
			if(shu[j]=='1'){
				flag=j;
			}
		}
		if(flag==0){
			cout<<-1<<endl;
			return 0;
		}
		else{
			ans++;
			i=flag;
		}
	}
	cout<<ans<<endl;
	return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main(){
	int n, d;
	cin >> n >> d;
	string s;
	cin >> s;
	int st = 0, ans = 0;
	for(int i = st; i < n - 1;){
		st = 0;
		for(int j = i + 1 ; j <= i + d; j++){
			if(s[j] == '1'){
				st = j;
			}
		}
		if(st != 0){
			i = st;
			ans++;
		}
		else{
			cout << -1;
			return 0;
		}
	}
	cout << ans << endl;
}

#include<bits/stdc++.h>

using namespace std;

/* ------------------ */

int n,d;
string Road;
int Sol = -1;              //if Solution Not Found ;
vector<int>Graph[105];
bool Visited[105];

void BFS(int Root){ /* Finding The Shortest Distance Between the first and the last Element */

    Visited[Root]++;

    queue<pair<int,int>>Q;                                                    // We need a Queue of Pairs (Node,Distance) ;

    Q.push(make_pair(Root,0));                                              //   But the Main Node ;

    while(Q.size()){                                                      //     While the Queue is Not Empty ;

        int Node = Q.front().first;
        int Moves = Q.front().second;
        Q.pop();                                                       //         Delete the Node ;

        if(Node == n-1){                                             //           If we Reach the last Element ;
            Sol = Moves;                                            //            Record the Level ;
            return;                                                //             End the Program ;
        }
        int Size = Graph[Node].size();
        for(int i = 0 ; i < Size ; i++){
            if (!Visited[Graph[Node][i]]){                      //                If there is an Unvisited Node yet ;
                Visited[Graph[Node][i]]++;
                Q.push(make_pair(Graph[Node][i],Moves+1));    //                  Put it in the Queue ;
            }
        }
    }
}

int main(){

    cin >> n >> d >> Road;

    for(int i = 0 ; i < n ; i++){
        for (int j = 1 ; j <= d ; j++){
                if(i+j >= n){                                //  If (i+j) Out of Bounds ;
                    continue;                               //   Don't Continue the loop Start Over ;
                }
                if(Road[i] == '1' && Road[i+j] =='1'){    //     If the (i) Element is '1' and the (i+j) Element is '1' ;
                    Graph[i].push_back(i+j);             //      Connect them Like a Graph ;
                }
        }
    }

    BFS(0);

    cout << Sol << endl;
}

#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;

int n, m;
char a[105];
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int now = 1; int step = 0;
	while (now < n) {
		int f = 0;
		for (int i = m; i >= 1; i--) {
			if (a[now + i] == '1') {
				f = 1;
				now = now + i;
				step++;
				break;
			}
		}
		if (f == 0) {
			cout << -1;
			return 0;
		}
	}
	cout << step;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main () {
    long long n , m , sum = 1 , sim = 0;
    char s[101];
    cin >> n >> m ;
  for (int i = 1 ; i <= n ; i++ ){
      cin >> s[i];
  }
  for ( int i = 1 ; i <= n ; i++ ) {
       if ( s[sum + m] == '1' ) {
        sum = sum + m;
        sim++;
       }
       else {
        for ( int j = m ; j >= 1 ; j-- ) {
            if ( s[sum + j] == '1' ) {
                sim++;
                sum = sum + j;
                break;
            }
        }
       }
  }
  if ( sum == n ) {
    cout << sim ;
  }
  else {
    cout << -1;
  }
}

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1000 + 5;

int n, k, a[MAXN], d[MAXN];
vector<int> v[MAXN];
queue<int> Q;
string S;

void Input()
{
    cin >> n >> k;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == '0')
            a[i + 1] = 0;

        else if (S[i] == '1')
            a[i + 1] = 1;
    }

    for (int i = 1; i <= n; i++)
    {
        if (a[i] == 1)
        {
            for (int j = i + 1; j <= n; j++)
            {
                if (a[j] == 1)
                    v[i].push_back(j);
            }
        }
    }
}

void Dijkstra()
{
    //fill_n(d, n + 1, 1e9);
    d[1] = 0;
    Q.push(1);
    while (!Q.empty())
    {
        int u = Q.front();
        Q.pop();
        for (int i = 0; i < v[u].size(); i++)
        {
            int t = v[u][i];
            if ((d[t] == 0 || d[u] + 1 < d[t]) && t - u <= k)
            {
                d[t] = d[u] + 1;
                Q.push(t);
            }
        }
    }
    if (d[n] != 0)
        cout << d[n] << '\n';
    else if (d[n] == 0)
        cout << -1 << '\n';
}

int main()
{
    Input();
    Dijkstra();
    return 0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include <queue>
using namespace std;
const int INF = 0x3f3f3f3f;
int ability,n;
char s[200];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        int cnt = 0,j,i = 1,die;
        scanf("%d",&ability);
        scanf("%s",s+1);
        while(i < n)
        {
            die = 1;
            for(j = min(i+ability,n);j>i;j--)
            {
                if(s[j] == '1'){i = j;die = 0;cnt++;break;}
            }
            if(die)break;
        }
        if(die)printf("-1\n");
        else printf("%d\n",cnt);
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int dp[100];
#define INF (999999)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, d;
    cin >> n >> d;
    string s;
    cin >> s;
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        if (s[i] == '1') {
            int m = INF;
            for (int j = max(i - d, 0); j < i; j++) {
                m = min(m, dp[j]);
            }
            if (m == INF) dp[i] = INF;
            else dp[i] = m + 1;
        }
        else {
            dp[i] = INF;
        }
    }
    if (dp[n-1] == INF) cout << "-1";
    else cout << dp[n-1];
}

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	int i, n, d, ok, tag;
	int len, start, count;
	char ch[110];
	ok = 1;
	start = count = 0;
	cin >> n >> d;
	scanf("%s", ch);
	len = strlen(ch);
	while (ok)
	{
		tag = 1;
		for (i = d; i > 0 && tag; i--)
		{
			if (ch[i + start] == '1')
			{
				start += i;
				tag = 0;
			}
		}
		count++;
		if (start == len - 1)	break;
		if (tag)	ok = 0;
	}
	if (ok)	cout << count << endl;
	else	cout << "-1" << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
char a[110];
int main() {
    int n, d;
    string a;
	cin>>n>>d>>a;
    int ans, l, r;
    ans = l = r = 0;
    for (int i = 0; i < n-1; ) {
        for(int j = 1; j <= d; ++j) {
            if (a[j+i] == '1') {
                r = max(r, j+i);
            }
        }
        if (l == r) {
            puts("-1");
            return 0;
        }
        l = i = r;
        ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

// dp-aWayToHome-codeForce.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
/******************A.The Way to Home
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
A frog lives on the axis Oxand needs to reach home which is in the point n.She starts from the point 1. The frog can jump to the right at a distance not more than d.So, after she jumped from the point x she can reach the point x  + a, where a is an integer from 1 to d.

For each point from 1 to n is known if there is a lily flower in it.The frog can jump only in points with a lilies.Guaranteed that there are lilies in the points 1 and n.

Determine the minimal number of jumps that the frog needs to reach home which is in the point n from the point 1. Consider that initially the frog is in the point 1. If the frog can not reach home, print - 1.

Input
The first line contains two integers n and d(2 ≤ n ≤ 100, 1 ≤ d ≤ n  - 1) — the point, which the frog wants to reach, and the maximal length of the frog jump.

The second line contains a string s of length n, consisting of zerosand ones.If a character of the string s equals to zero, then in the corresponding point there is no lily flower.In the other case, in the corresponding point there is a lily flower.Guaranteed that the firstand the last characters of the string s equal to one.

Output
If the frog can not reach the home, print - 1.

In the other case, print the minimal number of jumps that the frog needs to reach the home which is in the point n from the point 1.
*********************/

#include <iostream>
#include <algorithm>
using namespace std;

int n;
int d;
char s[200];
int dp[100];

int getMinStep(int index)
{
    int minStep = 999;
    int minIndex = index - d;
    if (minIndex < 0)
        minIndex = 0;
    for (int i = index-1; i >= minIndex; i--)
    {
        if (minStep > dp[i])
            minStep = dp[i];
    }
    return minStep + 1;
}
int main()
{
    cin >> n >> d;

    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        dp[i] = 999;
    }

    dp[0] = 0;

    for (int i = 1; i < n; i++)
    {
        if (s[i] == '1')
        {
            dp[i] = getMinStep(i);
        }
    }
    if (dp[n - 1] >= 999)
        cout << "-1" << endl;
    else
        cout << dp[n-1] << endl;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(nullptr);

    int n,d;
    cin >> n >> d;

    string s;
    cin >> s;

    vector<int> a(n),dp(n);
    for(int i=0;i<n;i++) {
        a[i]=s[i]-'0';
        dp[i]=1000000000;
    }
    dp[0]=1;
    for(int i=0;i<n;i++)
    {
        if (a[i]==1 && dp[i]>0)
        {
            for(int j=i+1; j<=i+d && j<n; j++)
                if(a[j]==1)
                    dp[j]=min(dp[j],dp[i]+1);
        }
    }

    if(dp[n-1]==1000000000)
        cout << -1;
    else
        cout << dp[n-1]-1;

    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int n, d;
    cin >> n >> d;
    int a=d, old=0, x=0;
    char s[n];
    for(int i=0; i<n; i++)
        cin >> s[i];
    while(a<=n-1){
        if(s[a] == '1'){
            a += d;
            if(a == old){
                x=-1;
                break;
            }
            old = a;
            if(d != n-1)
                x++;
        }else{
            a -= 1;
            if(a == old){
                x=-1;
                break;
            }
        }if(a>=n-1){
            x++;
            break;
        }
    }
    cout << x;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int n,d,flag=0,pos=0;

    cin>>n>>d;
    cin>>a;

    while(pos<n-1 && flag<=n)
    {
        if(a[pos]=='1')
        {
            flag++;
            pos=pos+d;
        }
        else
        {
            pos--;
        }
    }

    if(flag>=n)
    cout<<-1<<endl;
    else
    cout<<flag<<endl;

    return 0;
}

/*   __         .   __  ___        __   ___      ___
	|  \  |  |  |  /   |    |\  | |  \ |    | / |   | \    /
	|   | |  |  |  \   |--- | \ | |--/ |--- |-  |   |  \  /
	|__/  |__|  | __\  |___ |  \| |__/ |___ | \ |___|   \/
	             .            .
  	 	        / \   \  /   / \   |\  |
  	     	   /---\   \/   /---\  | \ |
  	          /     \  /   /     \ |  \|
*/
#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back
#define sz(a) (int)(a.size())
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <int, string> pins;
typedef pair <queue <int>, queue<int> > pqq;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;
int a[101], d[101];
char t;
queue <int> q;
main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cout.tie(0), cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		cin >> t;
		a[i] = t - 48;
	}
	q.push(1);
	d[1] = 1;
	while(!q.empty())
	{
		int v = q.front();
		q.pop();
		for(int j = 1; j <= m; j++)
		{
			if(!d[v + j] && a[v + j] == 1 && v + j <= n)
			{
				q.push(v + j);
				d[v + j] = d[v] + 1;
			}
		}
	}
	if(!d[n]) cout << -1;
	else cout << d[n] - 1;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define x first
#define y second

void EXIT_NO_SUCCESS (char* e) { puts(e); exit(0); }
void EXIT_NO_SUCCESS (int e) { printf("%d\n", e); exit(0); }

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pii;
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll Llinf = LLONG_MAX;
const int Inf = INT_MAX;
const int Maxn = 100 + 10;
const int Mod = 1e9 + 7;
const double Pi = acos(-1.0);

char* _c = new char[Maxn];
string GetString()
{
    scanf("%s", _c);
    return string(_c);
}

int n, d;
string s;
int dp[Maxn];

int main()
{
    #ifdef LOCAL
        clock_t _t = clock();
        freopen("i.txt", "r", stdin);
    #endif

    for (int i = 0; i < Maxn; i++) dp[i] = Inf / 2;

    scanf("%d%d", &n, &d);
    s = GetString();
    dp[0] = 0;

    for (int i = 0; i < n; i++)
        if (s[i] == '1')
            for (int j = 0; j < d; j++)
                if (s[i + 1 + j] == '1')
                    dp[i + 1 + j] = min(dp[i + 1 + j], dp[i] + 1);

    printf("%d\n", dp[n - 1] == Inf / 2 ? -1 : dp[n - 1]);

    #ifdef LOCAL
        cerr << (double)(clock() - _t) / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int n, d;
	while (cin >> n >> d) {
		int index=0, cnt = 0;
		bool flag;//Ҫע��flag�Ĳ��
		string s; cin >> s;
		while (index < n - 1) {
			flag = false;
			for (int i = min(n - 1, index + d); i > index; i--) {
				if (s[i] == '1') {
					index = i;
					cnt++;
					flag = true;
					break;
				}
			}
			if (!flag)break;
		}
		if (!flag) cout << -1 << endl;
		else cout << cnt << endl;
	}
}

#include <algorithm>
#include <array>
#include <cinttypes>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>

// From std.h

using namespace std;

// From iter/for_times.h

// A loop to repeat operation several times.
//
// * FOR_TIMES(n)
//   Repeats loop body n times, e.g.:
//   ` print("We all live in a");
//   ` FOR_TIMES(3) {
//   `     print(" yellow submarine");
//   ` }

#define FOR_TIMES(N_TIMES) \
    for (auto __counter = (N_TIMES); __counter > 0; --__counter)

// From util/macro.h

#define COMMA ,

#define NOOP()  do { } while (false)

// From util/check.h

// Assertions.
//
// - CHECK: assertion that is always enabled.
// - CHECK_DEFAULT: check that is by default enabled everywhere.
// - CHECK_DEBUG: check that is by default enabled only during local launches.
// - CHECK_INTERNAL: checks used to spot internal error in the library,
//       expected to be disabled during the contest, even locally.
//
// Warning. Never put statements with side effects in checks other than CHECK!
//
// TODO: Instruction on enabling/disabling checks.
//
// The same as above, in a table form:
//
//                | On server         | On local PC       | In library tests  |
// ---------------+-------------------+-------------------+-------------------+
// CHECK          | Yes               | Yes               | Yes               |
// CHECK_DEFAULT  | Yes by default    | Yes               | Yes/No            |
// CHECK_DEBUG    | No by default     | Yes               | Yes/No            |
// CHECK_INTERNAL | No                | No                | Yes/No            |
//
// Note that library is tested both with checks and without to make sure that
// optional CHECKs don't have side effects.  // TODO: Don't forget to actually do this.

namespace internal {
bool library_tests__enable_checks();
}  // namespace internal

// TODO: Print line and file, as assert does.
#define CHECK(EXPRESSION)     \
    do {                      \
      if (!(EXPRESSION))      \
        abort();              \
    } while (false)

#define INTERNAL_CHECK_CONDITIONALLY(EXPRESSION)  \
    do {                                          \
      if (library_tests__enable_checks())         \
        CHECK(EXPRESSION);                        \
    } while (false)

#ifndef CHECK_LEVEL
#  if defined LIBRARY_TEST
#    define CHECK_LEVEL 3
#  elif defined LOCAL_PC
#    define CHECK_LEVEL 2
#  else
#    define CHECK_LEVEL 1
#  endif
#endif

#if CHECK_LEVEL == 0
#  define CHECK_DEFAULT(EXPRESSION)   NOOP()
#  define CHECK_DEBUG(EXPRESSION)     NOOP()
#  define CHECK_INTERNAL(EXPRESSION)  NOOP()
#elif CHECK_LEVEL == 1
#  define CHECK_DEFAULT(EXPRESSION)   CHECK(EXPRESSION)
#  define CHECK_DEBUG(EXPRESSION)     NOOP()
#  define CHECK_INTERNAL(EXPRESSION)  NOOP()
#elif CHECK_LEVEL == 2
#  define CHECK_DEFAULT(EXPRESSION)   CHECK(EXPRESSION)
#  define CHECK_DEBUG(EXPRESSION)     CHECK(EXPRESSION)
#  define CHECK_INTERNAL(EXPRESSION)  NOOP()
#elif CHECK_LEVEL == 3
#  define CHECK_DEFAULT(EXPRESSION)   INTERNAL_CHECK_CONDITIONALLY(EXPRESSION)
#  define CHECK_DEBUG(EXPRESSION)     INTERNAL_CHECK_CONDITIONALLY(EXPRESSION)
#  define CHECK_INTERNAL(EXPRESSION)  INTERNAL_CHECK_CONDITIONALLY(EXPRESSION)
#endif

// From util/types.h

using uint = unsigned;
using int64 = int64_t;
using uint64 = uint64_t;

// From io/scan.h

// Input functions. Come in several flavours:
//
// * try_scan<T>
//   Reads T from standard input, sets success bit.
//   If the call had failed, the retuned value is undefined.
//   For convenience has alias called try_scan_T,
//   expect (T == std::string) where the alias is try_scan_word.
//   TODO: Consider:
//           - swapping arguments (set variable, return success)
//           - using optionals instead
//
// * scan<T>
//   Reads T from standard input. Abort on failure.
//   For convenience has alias called scan_T,
//   expect (T == std::string) where the alias is scan_word.
//
// * scan
//   Automagically reads any type from standard input.
//   Can be used like this: ``int x = scan();  foo(scan());''
//   Abort on failure.
//
// * SCAN_2, SCAN_3, ...
//   Returns a brace-enclosed sequence of N object that can be used
//   to call an N-argument constructor:
//   ``Foo f = SCAN_3();  vec.push_back(SCAN_2());''
//   To call an explicit constructor put SCAN_x next to the type name:
//   ``Foo f SCAN_3();  vec.push_back(Bar SCAN_2());''
//   WARNING: Doesn't work in gcc < 4.9.1 and in MSVC (see below) -
//            execution order is not defined.
//            TODO: Check clang.
//            TODO: Add compile-time checks.
//
// * scan(...)
//   Scans one of more values from the input.
//   Abort if at least one element cannot be read.
//
// * scan_vector(n), scan_vector_2(n), scan_vector_3(n), ...
//   Returns vector of n elements, each requiring the corresponding
//   number of arguments to construct.
//   WARNING: scan_vector_K versions inherit SCAN_K limitations.
//
// Supported types are:
//
// * int, uint, int64, uint64
//   A decimal representation of an integer.
//
// * float, double
//   A decimal representation of a floating-point number,
//   either in fixed or in exponential format.
//
// * char
//   An ASCII character.
//
// * std::string
//   A word, i.e. a sequence of characters surrounded by whitespace.
//   Leading whitespace is ignored.
//
// * line (std::string)
//   A sequence of characters up to a new-line character.
//   Leading "\n" are ignored; leading whitespace is not.
//   Trailing "\n" is consumed, but not included in the result.
//
// TODO: Execution order warning.
//
// WARNING. Scan functions rely both on cstdio (for chars, integers and floats)
//          and iostream (for strings), so std::ios_base::sync_with_stdio must
//          remain true!

#define DEFINE_SIMPLE_SCAN_TYPE(TYPE_NAME, FORMAT)  \
  template<>  \
  TYPE_NAME try_scan<TYPE_NAME>(bool& success) {  \
    TYPE_NAME result;  \
    success = (scanf(FORMAT, &result) > 0);  \
    return result;  \
  }

#ifdef LOCAL_PC

// Use iostream locally for redirections in unit tests
// TODO: Add checks so that it doesn't compile for unsupported types.
template<typename T>
T try_scan(bool& success) {
    T result;
    success = bool(std::cin >> result);
    return result;
}

#else

template<typename T>
T try_scan(bool& success);

// Use stdio remotely, because it's faster
DEFINE_SIMPLE_SCAN_TYPE(int, "%d");
DEFINE_SIMPLE_SCAN_TYPE(uint, "%u");
DEFINE_SIMPLE_SCAN_TYPE(int64, "%" SCNd64);
DEFINE_SIMPLE_SCAN_TYPE(uint64, "%" SCNu64);
DEFINE_SIMPLE_SCAN_TYPE(float, "%f");
DEFINE_SIMPLE_SCAN_TYPE(double, "%lf");
DEFINE_SIMPLE_SCAN_TYPE(char, "%c");  // TODO: sync with iostream (in terms of whitespace treatment)

template<>
std::string try_scan<std::string>(bool& success) {
    std::string result;
    success = bool(std::cin >> result);
    return result;
}

#endif

#if 0  // TODO try
template<typename Arg>
std::tuple<Arg> try_scan<std::tuple<Arg>>(bool& success) {
    return std::make_tuple(try_scan<Arg>(success));
}

template<typename Head, typename... Tail>
std::tuple<Head, Tail> try_scan<std::tuple<Head, Tail>>(bool& success) {
    auto head = try_scan<Head>(success);
    if (!success)
        return {};
    auto tail = try_scan<Tail>(success);
    return std::tuple_cat(head, tail);
}
#endif

inline int try_scan_int(bool& success)          { return try_scan<int>(success);    }
inline uint try_scan_uint(bool& success)        { return try_scan<uint>(success);   }
inline int64 try_scan_int64(bool& success)      { return try_scan<int64>(success);  }
inline uint64 try_scan_uint64(bool& success)    { return try_scan<uint64>(success); }
inline float try_scan_float(bool& success)      { return try_scan<float>(success);  }
inline double try_scan_double(bool& success)    { return try_scan<double>(success); }
inline char try_scan_char(bool& success)        { return try_scan<char>(success);   }
inline std::string try_scan_word(bool& success) { return try_scan<std::string>(success); }

inline std::string try_scan_line(bool& success) {
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    std::string result;
    success = bool(std::getline(std::cin, result));
    return result;
}

template<typename T>
T scan() {
    bool success = false;
    T result = try_scan<T>(success);
    CHECK(success);
    return result;
}

inline int scan_int()           { return scan<int>();    }
inline uint scan_uint()         { return scan<uint>();   }
inline int64 scan_int64()       { return scan<int64>();  }
inline uint64 scan_uint64()     { return scan<uint64>(); }
inline float scan_float()       { return scan<float>();  }
inline double scan_double()     { return scan<double>(); }
inline char scan_char()         { return scan<char>();   }
inline std::string scan_word()  { return scan<std::string>(); }

inline std::string scan_line() {
    bool success = false;
    std::string result = try_scan_line(success);
    CHECK(success);
    return result;
}

class ScanResult {
public:
    ScanResult(const ScanResult&) = delete;
    ScanResult& operator=(const ScanResult&) = delete;
    ScanResult(ScanResult&&) = delete;
    ScanResult& operator=(ScanResult&&) = delete;

    template<typename T>
    operator T() && {
        return scan<T>();
    }
};

ScanResult scan() {
    return {};
}

// TODO: fix for std::string
#define SCAN_2()  {scan(), scan()}
#define SCAN_3()  {scan(), scan(), scan()}
#define SCAN_4()  {scan(), scan(), scan(), scan()}
#define SCAN_5()  {scan(), scan(), scan(), scan(), scan()}
#define SCAN_6()  {scan(), scan(), scan(), scan(), scan(), scan()}
#define SCAN_7()  {scan(), scan(), scan(), scan(), scan(), scan(), scan()}
#define SCAN_8()  {scan(), scan(), scan(), scan(), scan(), scan(), scan(), scan()}

template<typename Arg>
void scan(Arg& arg) {
    arg = scan<Arg>();
}

template<typename Head, typename... Tail>
void scan(Head& head, Tail&... tail) {
    scan(head);
    scan(tail...);
}

#define DEFINE_SCAN_VECTOR_N(NAME, SCAN_FUNCTION)  \
template<typename ElementT>  \
std::vector<ElementT> NAME(size_t n_elements) {  \
    CHECK(ssize_t(n_elements) >= 0);  \
    std::vector<ElementT> result;  \
    result.reserve(n_elements);  \
    FOR_TIMES(n_elements) {  \
        result.push_back(SCAN_FUNCTION);  \
    }  \
    return result;  \
}

DEFINE_SCAN_VECTOR_N(scan_vector, scan())
DEFINE_SCAN_VECTOR_N(scan_vector_2, SCAN_2())
DEFINE_SCAN_VECTOR_N(scan_vector_3, SCAN_3())
DEFINE_SCAN_VECTOR_N(scan_vector_4, SCAN_4())
DEFINE_SCAN_VECTOR_N(scan_vector_5, SCAN_5())
DEFINE_SCAN_VECTOR_N(scan_vector_6, SCAN_6())
DEFINE_SCAN_VECTOR_N(scan_vector_7, SCAN_7())
DEFINE_SCAN_VECTOR_N(scan_vector_8, SCAN_8())

#undef DEFINE_SCAN_VECTOR_N

// From util/compilers.h

template<typename... Args>
void FIX_UNUSED(const Args&...) {}

// From io/targets.h

struct IOFileNames {
public:
    std::string input_file_name;
    std::string output_file_name;
};

IOFileNames input_txt_output_txt() {
    return {"input.txt", "output.txt"};
}
IOFileNames foo_in_foo_out(const std::string& file_name_base) {
    return {file_name_base + ".in", file_name_base + ".out"};
}
IOFileNames custom_file_names(const std::string& input_file_name, const std::string& output_file_name) {
    return {input_file_name, output_file_name};
}

void set_io_file_names(const IOFileNames& names) {
    FIX_UNUSED(names);
#ifndef LOCAL_PC
    freopen(names.input_file_name.c_str(), "r", stdin);
    freopen(names.output_file_name.c_str(), "w", stdout);
#endif
}

// From codeforces/910/A/a.cpp

class SolverA {
public:
  void run();
};

void SolverA::run() {
  int n = scan();
  int d = scan();
  string s = scan();
  CHECK(n == s.size());
  int x = 0;
  int num_jumps = 0;
  while (x < n - 1) {
    int y = min(x + d, n - 1);
    while (s[y] == '0' && y > x)
      --y;
    if (y <= x) {
      std::cout << -1;
      return;
    }
    x = y;
    ++num_jumps;
  }
  std::cout << num_jumps;
}

int main() {
    SolverA solver;
    solver.run();
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    string s;
    cin>>s;
    int dp[105];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        if(dp[i]!=-1)
        {
            int temp=i+1;
            while(temp<n &&temp<=i+d)
            {
                if(s[temp]=='1')
                {
                    if(dp[temp]==-1)
                    dp[temp]=dp[i]+1;
                    else
                    dp[temp]=min(dp[temp],dp[i]+1);
                }
                temp++;
            }
        }
    }
    cout<<dp[n-1]<<endl;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	int n,d,dp[105],res;
	string str;
	cin>>n>>d;
	cin>>str;
	dp[0] = 0;
	for(int i = 1; i < n; ++i){
		if(str[i] == '1'){
			res = INT_MAX;
			for(int j = i-1; j >= 0 && j >= i-d; --j){
				if(str[j] == '1'){
					res = min(res, dp[j]);
				}
			}
			dp[i] = (res == INT_MAX) ? INT_MAX : (res + 1);
		}
	}
	res = (dp[n-1] == INT_MAX) ? -1 : dp[n-1];
	cout<<res<<endl;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define LL long long
using namespace std;
const int maxn=1e9+7;
const int mod=1e9+7;
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
int n,d;
char s[1002];
int f=0,minn=inf;
void  dfs(int x,int cnt)
{

    if(x==n)
    {
        minn=cnt;
        f=1;
        return ;
    }
    for(int i=d; i>=1; i--)
    {
        if(s[i+x]=='1'&&x+i<=n)
            {dfs(i+x,cnt+1);
            break;}
    }
    return  ;
}
int main()
{

    cin>>n>>d;
    cin>>(s+1);
    dfs(1,0);
    if(minn==inf)
        cout<<-1<<endl;
    else
        cout<<minn<<endl;

    return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
void main() {
	int t, n,sw=0,p=0;
	cin >> t >> n;
	string s;
	cin >> s;
	for (int i = t - 1 - n; i >= 0-n; i++) {
		if (p == n) {
			cout << -1;
			break;
		}
		if (i <= 0) {
			sw++;
			break;
		}
		if (s[i] == '1') {
			sw++;
			i--;
			i -= n;
			p = 0;
		}
		else p++;
		if (i== -1) {
			sw++;
			break;
		}
	}
	if (p != n) {
		cout << sw;
	}
}

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n , d, dp[102];
    string s;
    cin >> n >> d;
    cin >> s;

    for(int i =1; i<=n-1; i++)dp[i]=123456;
    dp[0]=0;
    for(int i = 1;i<=n-1; i++){
        for(int j = i; j>=0&& j >=i-d; j--){
                if(s[j]=='1')
            dp[i]= min(dp[i], dp[j]+1);
        }
    }
    if(dp[n-1]<=n)
    cout << dp[n-1];
    else cout << -1;

return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 101;
int n,d;
string lily;
int dfs(int node){

    if(node == n-1) return 1;

    for(int i = d + node;i >= node + 1;i--){
        if(lily[i] == '1'){
            int r = dfs(i);
            if(r != MAX)
                return r + 1;
            return MAX;
        }
    }

    return MAX;
}
int main()
{
    cin >> n >> d >> lily;
    int c = dfs(0);
    if(c != MAX){
        cout << c - 1 << endl;
    }
    else cout << -1 << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int m,n,ans=0,x,i;
	cin>>m>>n;
	string t;
	cin>>t;if(m>n+1)
	{for(i=n;i<m;i+=n)
	{
	    x=i-n;
	    while(t[i]!='1')
	    {i--;
	        if(i<=x)
	    {cout<<"-1";return 0;
	    }}
	    ans+=1;
	}
	if(((i-m+1)<n)&&(i>=m))++ans;
	}
	else
	ans=1;
	cout<<ans;
	return 0;
}

#include <iostream>
using namespace std;
#define MaxSize 200
int main(){
    int n, d;
    cin >> n >> d;
    string str;
    cin >> str;
    int arr[MaxSize];
    int i, j, k = 0;
    for (i = 0, j = 0; i < n; ++i) {
        if(str[i] == '1'){
            arr[j++] = i + 1;
        }
    }
    int pre = arr[0], cnt = 0, flag = 0;
    while (k < j) {
        if((arr[k] - pre) <= d) {
            k++;
            continue;
        }
        else {
            if(arr[k] > arr[k - 1] + d) {
                flag = 1;
                break;
            } else {
                pre = arr[k - 1];
                cnt++;
            }
        }
    }
    if(flag) {
        cout << -1 << endl;
    }
    else if(pre < arr[k - 1]) {
        cout << cnt + 1 << endl;
    }
    return 0;
}

#include <iostream>
#include<stdlib.h>

using namespace std;

int minimum(char *Arr,int s, int m)
{
    int countt=0;
    int index = 0;
    int i;

    while(true)
    {

        for(i=m ; i>0 ; i--)
        {
            if(Arr[index+i] == '1')
            {
                countt++;
                index += i;
                break;
            }
            if(Arr[index+1] == '0' && i==1) return -1;

        }

        if(Arr[index+1]=='\0') return countt;

    }

}

int main()
{
    int s,m;
    cin >> s;
    char *Arr = (char*) malloc(s+1);
    Arr[s] = '\0';
    cin >> m;
    cin >> Arr;
    cout << minimum(Arr, s, m);

    return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{

    ll n, d;
    cin >> n >> d;
    string pond;
    cin >> pond;
    ll mem[105];
    memset(mem, -1, sizeof(mem));
    mem[0] = 0;
    ll cnt = 1;
    for (int i = 0; i < n - 1; i++)
    {
        if (mem[i] != -1)
        {
            ll temp = i + 1;
            while (temp < n && temp <= d + i)
            {
                if (pond[temp] == '1')
                {
                    if (mem[temp] == -1)
                        mem[temp] = mem[i] + 1;
                    else
                        mem[temp] = min(mem[temp], mem[i] + 1);
                }
                temp++;
            }
        }
    }
    cout << mem[n - 1] << endl;
    ////////////////////////

    // long n, d;
    // std::cin >> n >> d;
    // std::string s;
    // std::cin >> s;
    // std::vector<long> v;
    // for (long p = 0; p < s.size(); p++)
    // {
    //     if (s[p] == '1')
    //     {
    //         v.push_back(p);
    //     }
    // }
    // std::vector<long> w(v.size(), n + 1);
    // w[0] = 0;

    // for (long from = 0; from < v.size(); from++)
    // {
    //     for (long to = from + 1; to < v.size(); to++)
    //     {
    //         if (v[to] - v[from] <= d)
    //         {
    //             if (w[to] <= w[from] + 1)
    //                 w[to] = w[to];
    //             else
    //                 w[to] = (w[from] + 1);
    //             cout << "W: " << w[to] << endl;
    //         }
    //         else
    //         {
    //             break;
    //         }
    //     }
    // }

    // std::cout << ((w.back() <= n) ? w.back() : -1) << std::endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{

    long n, d;
    std::cin >> n >> d;
    std::string s;
    std::cin >> s;
    std::vector<long> v;
    for (long p = 0; p < s.size(); p++)
    {
        if (s[p] == '1')
        {
            v.push_back(p);
        }
    }
    std::vector<long> w(v.size(), n + 1);
    w[0] = 0;
    for (long from = 0; from < v.size(); from++)
    {
        for (long to = from + 1; to < v.size(); to++)
        {
            if (v[to] - v[from] <= d)
            {
                w[to] = (w[to] <= w[from] + 1) ? w[to] : (w[from] + 1);
            }
            else
            {
                break;
            }
        }
    }

    std::cout << ((w.back() <= n) ? w.back() : -1) << std::endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int INF = 1e5;
int n, d, dp[101];
string a;

int main(){
	cin >> n >> d;
	cin >> a;
	for(int i = 0 ; i < n ; i++)
		dp[i] = INF;
	dp[0] = 0;
	for(int i = 1 ; i < n ; i++){
		if(a[i] == '1'){
			for(int j = 1 ; j <= d ; j++)
				if(i - j > -1)
					if(a[i - j] == '1'){
						dp[i] = min(dp[i], dp[i - j] + 1);
					}
		}
	}
	if(dp[n - 1] == INF)
		cout << -1;
	else
		cout << dp[n - 1];
}

#include<bits/stdc++.h>
using namespace std;
int now=1,cnt;
int main()
{
	int n,d;
	cin>>n>>d;
	char s[2000];
	scanf("%s",s+1);
	int l=strlen(s);
	while(now!=n)
	{
		if(now+d>=n)
		{
			cnt++;
			break;
		}
		int flag=0;
		for(int i=now+d;i>now;i--)
		{
			if(s[i]=='1')
			{
				now=i;
				cnt++;
				flag=1;
				continue;
			}
		}
		if(flag==0)
		{
			cout<<"-1";
			return 0;
		}
	}
	cout<<cnt;
	return 0;
}

#include <iostream>
#include <fstream>
#include <string>

template <typename T>
T max(int size, const T* data)
{
	T maximal = data[0];
	for (int i = 0; i < size; ++i) if (data[i] > maximal) maximal = data[i];

	return maximal;
}

int a_910(int n, int d, std::string can_jump_at)
{
	int count = 0;
	int current_x = 0;

	while (current_x < n - 1)
	{
		for (int i = d; i > 0; --i)
		{
			if (current_x + i >= n || can_jump_at[current_x + i] == '1')
			{
				current_x += i;
				break;
			}

			else if (i == 1) return -1;
		}

		++count;

	}

	return count;

}

int main()
{
	int n, d;
	std::string str;
	std::cin >> n >> d >> str;
	int* data = new int[n];

	/*
	for (int i = 0; i < n; ++i)
	{
		data[n - i - 1] = tmp % 10;

		tmp /= 10;
	}
	*/

	//for (int i = 0; i < n; ++i) std::cout << data[i];
	//std::cout << "\n";

	std::cout << a_910(n, d, str);

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,m;
string s;
bool jii=0;
void dfs(int k,int zhi)
{
	if(jii==1)
	return;
	if(k==n-1)
	{
		cout<<zhi;jii=1;
		return ;
	}
	int jij=0;
	int i=k+m;
	for(int i=k+m;i>=k+1;i--)
	{
		if(i>=0&&i<n&&s[i]=='1'&&jij==0)
		{
			dfs(i,zhi+1);jij=1; break;
		}
	}
	if(k+m>=n-1&&jij==0)
	{
		jii=1;cout<<-1;return;
	}
}
int main()
{
	cin>>n>>m;
	cin>>s;
	dfs(0,0);
	if(jii==0)
	cout<<-1;
}

 #include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
#define INF  0x7f7f7f7f7f7f7f7f
#define M 500005
#define N 200005
const ll mod = 1e9+7;
ll n,d,dis[N],vis[N];
vector<vector<ll> >e(N);
queue<ll>q;
string s;
void solve(ll w){
	for(ll i = w+1;i<n&&i -w <=d;i++)
	if(s[i]=='1')
	e[w].push_back(i);
}
int main(void){
	cin>>n>>d;
	for(ll i = 0;i < n;i++)
	dis[i] = INF;
	cin>>s;
	for(ll i = 0;i < n;i++)
	solve(i);
	vis[0] = 1;
	dis[0] = 0;
	q.push(0);

	while(!q.empty()){
		ll u = q.front();
		q.pop();
		vis[u] = 0;
		for(ll i = 0;i <e[u].size();i++){
			ll v =e[u][i];
			ll ls =dis[v];
			dis[v] = min(dis[v],dis[u]+1);
			if(ls!=dis[v]&&!vis[v]){
				q.push(v);
				vis[v] = 1;
			}
		}
	}
	if(dis[n-1]==INF)
	cout<<-1<<endl;
	else
	cout<<dis[n-1]<<endl;
}

#include<bits/stdc++.h>
using namespace std;

int main(){

    /// I faced problem implementing this code , specially while finding out the logic

    /// logic is :
    /// search every i+d index whether there is a lily flower( ~1 )
    /// if you don't find lily on i+d index ...then , decrease value of d
    /// like do ," d--" operation
    /// now just normally count all steps

    int n , d , prev_one_index = 0 ; cin>> n >> d ;
    string s ; cin>> s ;

    for( int i=0 ; i< n ; i++){
        if( i==0 ) {
            prev_one_index= i ;
        }
        else if( s[i]=='1' and i>0 ) {
            if( i-prev_one_index  > d ){
                cout<<"-1\n"; return 0;
            }
            else
                prev_one_index= i ;
        }
    }

    int step= 0 ;

    for( int i=0 ;; )
    {
        int j=i+d ;

        while(j>i ){
            if( (char) s[j]=='1' ){
                step++;
                break;
            }
            j--;
        }

        i = j ;

        if( i==n-1 ){ /// corner case, ( if frog can jump from i=0 to i=n-1 in 1 step )
            break;
        }
        else
        if( i+d>=n-1 )
        {
            step++; break;
        }
    }

    cout<< step << endl;
    return 0;

}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define MOD 1000000007

int main() {
    int n, d, ctx = 0, i = 0;
    cin >> n >> d;

    string s;
    cin >> s;

    bool win = false;
    while (i < s.size()) {
        int x = i;
        i = i + d;
        ctx = ctx + 1;

        while (s[i]!='1' && i>x) i--;
        if (i == n-1) {
            win = true;
            break;
        }
        else if (i == x) break;
    }
    if(win) cout << ctx << endl;
    else cout << -1 << endl;
}

//spfa 队列优化
#include <bits/stdc++.h>
using namespace std;
int dis[105];
int head[105],cnt;
int vis[105],a[105];
int n,d;
const int INF = 9999999;
struct Edge{
	int v,nxt;
};
Edge edge[1005];
void add(int u,int v){
	cnt++;
	edge[cnt].v = v;
	edge[cnt].nxt = head[u];
	head[u] = cnt;
}
void spfa(){
	for(int i=0;i<=n;i++)dis[i] = INF;
	queue<int> q;
	dis[1] = 0; vis[1] = 1; q.push(1);
	while(!q.empty()){
		int u = q.front(); q.pop(); vis[u] = 0;
		for(int v,w,i=head[u];i;i=edge[i].nxt){
			v = edge[i].v; w = dis[u]+1;
			if(dis[v]>w){
				dis[v] = w;
				if(!vis[v]) vis[v]=1,q.push(v);
			}
		}

	}
}

int main() {
    scanf("%d%d",&n,&d);
    while(getchar()!='\n');
    for(int i=1;i<=n;i++)  a[i]=getchar();
    for(int i=1;i<=n;i++)
        if(a[i]=='1')  for(int j=1;j<=d&&i+j<=n;j++)  add(i,i+j);
    spfa();
    if(dis[n]==INF)  puts("-1");
    else  printf("%d",dis[n]);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int n, d; string s;
vector<int> ans;
int dp[105][105];
bool check = false;
int fun(int pos, int current){
    /*if(pos == 0){
        check = true;
        return current;
    }
    if(dp[pos][current] != -1){
        return dp[pos][current];
    }
    int minn = 1e9;
    for(int i = pos - 1; i>= pos - d && i>=0; i--){
        if(s[i] == '1'){
           minn = min(fun(i, current + 1), minn);
        }
    }
    dp[pos][current] = minn;
    return dp[pos][current];
    /**/
    if(pos == 0){
        return current;
    }
    if(pos < 0){
        return 1e9;
    }
    if(s[pos] == '0'){
        return 1e9;
    }
    if(dp[pos][current] != -1){
        return dp[pos][current];
    }
    int minn = 1e9;
    for(int i = pos - 1; i>= pos - d; i--){
        minn = min(minn, fun(i, current + 1));
    }
    dp[pos][current] = minn;
    return dp[pos][current];
}
int main(){
    cin >> n >> d;
    cin >> s;
    /*int cnt = 0; int pos = 0;
    vector<int> ones;
    for(int j = 0; pos != n - 1; j++){
        for(int i = n - 1; i >= pos; i--){
            if(i == pos){
                cout << -1 << endl;
                return 0;
            }
            if(s[i] == '1' && i - pos <= d){
                cnt++;
                pos = i;
                break;
            }
        }
    }/**/
    for(int i = 0; i < 105; i++){
        for(int j = 0; j < 105; j++){
            dp[i][j] = -1;
        }
    }
    /*(fun(n - 1, 0);
    if(ans.size() != 0){
        sort(ans.begin(), ans.end());
        cout << ans[0] << endl;
        return 0;
    }
    cout << -1;
    //cout << cnt << endl;
    /**/
    /*if(check){
        cout << "hi" << endl;
        cout << fun(n-1, 0) << endl;
    }
    else{
        cout << -1 << endl;
    }
    /**/
    fun(n-1, 0);
    if(dp[n-1][0] == 1e9){
        cout << -1;
        return 0;
    }
    cout << dp[n - 1][0];
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define vll vector<ll>
#define mp make_pair
#define pb push_back
#define f1(i,a,n) for(ll i=a;i<n;i++)
#define f2(i,a,n) for(ll i=n;i>a;i--)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test int T; cin>>T; while(T--)
#define in(x) ll x;cin>>x
#define out(x) cout<<x
#define M 1000000007
#define line cout<<endl
/* BIRLA INSTITUTE OF TECHNOLOGY*/
int main(){
fast;
in(n);in(k);
string s;cin>>s;ll mark=0, next=1 ,jumps=0;
for(ll i=1;i<=k;i++){
   // if(mark)break;
   // cout<<"* "<<s[i]<<mark<<endl;
    if(s[i] == '1'){mark=1; next=i;}

}
ll mark1=0;
//cout<<"initial " <<next<<endl;
if(mark){
    jumps++;
    while(next!= n-1){
        ll flag=0,temp=next;
   // cout<<"begin "<<next<<endl;
        if(next+k <= n-1){
            for(ll i=1;i<=k;i++){
              if(s[temp+i] == '1'){flag=1; next=i;}
            }
        next+=temp;
        }
        else {flag=1;next=n-1;}
   // cout<<"end "<<next<<"*"<<flag<<endl;
    jumps++;
    if(!flag){mark1=1;break;}

  }

if(mark1)cout<<-1<<endl;
else cout<<jumps<<endl;

}
else cout<<-1<<endl;

return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, d; cin >> n >> d;
    string s; cin >> s;
    int cnt = 0; int pos = 0;
    vector<int> ones;
    for(int j = 0; pos != n - 1; j++){
        for(int i = n - 1; i >= pos; i--){
            if(i == pos){
                cout << -1 << endl;
                return 0;
            }
            if(s[i] == '1' && i - pos <= d){
                cnt++;
                pos = i;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, d;
	cin >> n >> d;
	string s;
	cin >> s;
	int x = 0, y = 0;
	while (x < n - 1 && y <= n) {
		if (s[x] == '1')
			x += d, ++y;
		else
			--x;
	}
	if (y >= n)
		cout << -1;
	else
		cout << y;
	return 0;
}

#include<iostream>
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n,d;
	char c;
	cin>>n>>d;
	int i=d;
	string s;
	cin>>s;
	int jmp1=0;
	int pre=0;
	while(i!=pre && pre!=n-1){
		if(i<n && s[i]=='1'){
			//cout<<i<<endl;
			jmp1++;
			pre=i;
			i=i+d;
		}
		else{
			i--;
		}
	}
	if(pre!=n-1)
		cout<<-1;
	else
		cout<<jmp1;
}

#include <iostream>
//8 4
//10010101
using namespace std;
int main(){
    int clilPads , jumpDistance;
    cin >> clilPads >> jumpDistance;
    int n = clilPads;
    int jumpNeeded = 0;
    string theWholePath;
    cin >> theWholePath;
    while(clilPads > 0){
        int howFarCanIGo=0;
        int path,i=1;
        while(i <= jumpDistance){
//            cout << theWholePath.at(n - clilPads + i) << "\n";
            path = theWholePath.at(n - clilPads + i) == '0' ? 0 : 1;
            if(path == 1){
                howFarCanIGo = i;
            }
            i++;
        }
//        cout << "\nI'm meteorically jumping to " << howFarCanIGo << "\n";
        if(howFarCanIGo == 0){
            cout << -1;
            return 0;
        }
        clilPads -= (howFarCanIGo-1);
        jumpNeeded++;
        clilPads--;
        if(clilPads <= jumpDistance){
//            cout << "\nI am at : " << clilPads << "\n";
            jumpNeeded = clilPads > 1 ? jumpNeeded + 1 : jumpNeeded;
            cout << jumpNeeded;
            return 0;
        }
    }
    cout << jumpNeeded;
    return 0;
}

#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vl                    vector<ll>
#define SZ(x)                 (x).size()
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
using namespace std;
bool file=0,rt=1;
clock_t tStart ;
void FAST_IO();
////////////////////////

int main()
{

    FAST_IO();
    ////////////////////////
    ll n, d;
    cin>>n>>d;
    string pond;
    cin>>pond;
    ll mem[105];
    memset(mem,-1,sizeof(mem));
    mem[0]=0;
    ll cnt=1;
    for(int i=0 ; i< n-1 ; i++){
        if(mem[i]!=-1){
            ll temp=i+1;
            while(temp<n && temp<=d+i ){
                if(pond[temp]=='1'){
                    if(mem[temp]==-1)
                        mem[temp]=mem[i]+1;
                    else
                        mem[temp]=min(mem[temp],mem[i]+1);
                }
                temp++;
            }
        }
    }
    cout<<mem[n-1]<<endl;
    ////////////////////////
    if(rt && file){
     printf("\nTime taken: %.6fs", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    }
    return 0;
   }

void FAST_IO()
{
    ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);
    if(rt && file){ tStart = clock(); }
    if(file){
    #ifndef _offline
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    }
}

#include<iostream>
using namespace std;
int main()
{
 int n,d,ans=0;
 string s;
 cin>>n>>d>>s;
 int pos=0;
 while(pos<n-1)
 {
   int i=min(n-1,pos+d);
   while(s[i]=='0')
   i--;
   if(i==pos)
   {	cout<<"-1";
   return 0;	}
   pos=i;
   ans++;
 }
 cout<<ans;
}

#include <bits/stdc++.h>
#define inf 1000000000
using namespace std;
//int arr[1000000];
vector<int >arr,res;
int a,b;
string str;
int sub(int i){
    if(i==a-1) return 0;
    if(i>=a) return inf;
    if(arr[i]!=inf) return arr[i];
    int p=inf;
    for(int j=i+b;j>=i+1;j--){
        if(str[j]=='1'){
            p=min(p,1+sub(j));
            break;
        }
    }
    return arr[i]=p;
}
int main(){
    int c,e,d;
    cin>>a>>b;
    cin>>str;
    for(int i=0;i<a;i++){
        arr.push_back(inf);
    }
    c=sub(0);
    if(c==inf) cout<<-1<<endl;
    else cout<<c<<endl;
}

#include<bits/stdc++.h>
using namespace std ;

int main()
{
    int n,d,cnt=0,pos=0;
    string s;
    cin>>n>>d;
    cin>>s;
    if(s[0]=='0'||s[n-1]=='0'){
        cout<<"-1"<<endl;
        return 0;
    }
    for(int i=0; i<n-1; ){
        for(int j=1; j<=d; j++){
            if(s[i+j]=='1')pos=i+j;
        }
        if(pos==i){cout<<"-1"<<endl;
        return 0;}
        else{
            cnt++;
            i=pos;
        }
    }

    cout<<cnt<<endl;
}

#include<cstdio>
#include<climits>
#include<iostream>
#include<cstring>
using namespace std;
int k[100001],d,n,h,t,q[1000001];
bool v[100001],jg[100001];
string a;
int main(){
	scanf("%d%d",&n,&d);
	cin>>a;
	for(int i=0;i<n;i++){
		if(a[i]=='1')jg[i+1]=true;
		else jg[i+1]=false;
	}
	for(int i=2;i<=n;i++){
		k[i]=INT_MAX;
	}
	q[t++]=1;
	v[1]=true;
	while(h<t&&v[n]==false){
		int x=q[h];
		for(int i=x+1;i<=x+d;i++){
			if(jg[i]==true&&v[i]==false){
				q[t++]=i;
				k[i]=min(k[i],k[x]+1);
				v[i]=true;
			}
		}
		h++;
	}
	if(v[n]==false){
		printf("-1");
		return 0;
	}
	printf("%d",k[n]);
}

#include<cstdio>
#include<queue>
#define N 105
#define inf 0x3f3f3f3f
using namespace std;

int n,d,cnt;
char a[N];
int dis[N],head[N];
bool vis[N];
struct Edge{
    int v,nxt;
}edge[N*N];

inline void add(int u,int v)
{
    cnt++;
    edge[cnt].v=v;
    edge[cnt].nxt=head[u];
    head[u]=cnt;
}
void spfa()
{
    for(int i=1;i<=n;i++)  dis[i]=inf;
    queue<int> q;
    dis[1]=0;  vis[1]=1;  q.push(1);
    while(!q.empty())
    {
        int u=q.front();  q.pop();  vis[u]=0;
        for(int v,w,i=head[u];i;i=edge[i].nxt)
        {
            v=edge[i].v;  w=dis[u]+1;
            if(dis[v]>w)
            {
                dis[v]=w;
                if(!vis[v])  vis[v]=1,q.push(v);
            }
        }
    }
}
int main()
{
    scanf("%d%d",&n,&d);
    while(getchar()!='\n');
    for(int i=1;i<=n;i++)  a[i]=getchar();
    for(int i=1;i<=n;i++)
        if(a[i]=='1')
            for(int j=1;j<=d&&i+j<=n;j++)
                if(a[j+i]=='1')
                    add(i,i+j);
    spfa();
    if(dis[n]==inf)  puts("-1");
    else  printf("%d",dis[n]);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
struct edge
{
	int v,next;
}e[10000];
int cnt,n,p;
int d[10000],h[10000];
bool f[10000];
queue<int> q;
char s[10000];
void add_edge(int u,int v)
{
	e[++cnt]=(edge){v,h[u]};
	h[u]=cnt;
}
void find_ans()
{
	d[1]=0;
	f[1]=1;
	q.push(1);
	while(!q.empty())
	{
		int temp=q.front();
		q.pop();
		f[temp]=0;
		for(int i=h[temp];i;i=e[i].next)
		{
			int v=e[i].v,w=d[temp]+1;
			if(d[v]>w)
			{
				d[v]=w;
				if(!f[v])
				{
					f[v]=1;
					q.push(v);
				}
			}
		}
	}
}
int main()
{
	scanf("%d%d",&n,&p);
	while(getchar()!='\n');
	for(int i=1;i<=n;++i)
		s[i]=getchar();
	for(int i=1;i<=n;++i)
		if(s[i]=='1')
			for(int j=1;j<=p&&i+j<=n;j++)
				add_edge(i,i+j);
	for(int i=1;i<=n;++i)
		d[i]=0x3f3f3f3f;
	find_ans();
	if(d[n]==0x3f3f3f3f) printf("-1");
	else printf("%d",d[n]);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>v;
    int n,t,c=0,temp=0;
    cin>>n>>t;
    string s;
    cin>>s;
    int ans=0+t;
    int a[n];
    for(int i=0;i<n;i++){
        a[i]=0;

    }

    while(ans<s.size()){

    if(s[ans]=='1' && a[ans]==0){
        a[ans]=1;
        c++;
       ans=ans+t;

     }

    else if(a[ans]==0 && s[ans]=='0'){
        a[ans]=1;
        ans--;

        if(ans==0 ){

            break;
        }

    }

 else{
    temp=1;

    break;

 }

    }

   if(ans-t==s.size()-1 && temp==0){
        c=c;
    }
    else {
            int p=ans-t+1;
        if(p+t>n){
            c=c+1;
        }
    }
    if(c==0 && temp==0){
        cout<<-1<<endl;
    }

    else if(c!=0 && temp==0){
        cout<<c<<endl;
    }
    else if(c!=0 && temp!=0){
        cout<<-1<<endl;
    }

}

#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n,d,count=0,m=0,q=0;
    string s;

    cin >> n >> d;
    cin >> s;

    int pos=1;

    while(pos<n)
    {
        int i=min(n-1,pos+d-1);
        while(s[i]=='0')
            i--;
        if(i+1==pos)
        {
            cout << -1 << '\n';
            return 0;
        }
        pos = i+1;
        count++;
    }
    cout << count << '\n';
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, d;
	cin >> n >> d;
	string s;
	cin >> s;
	int cnt = 0;
	int ans = 0;
	int can_reach = d;
	bool flag = false;
	while (ans <= can_reach && !flag)
	{
		bool flag2 = true;
		if (can_reach >= n - 1)
		{
			flag = 1;
			break;
		}
		for (int i = can_reach; i > ans; i--)
			if (s[i] == '1')
			{
				ans = i;
				can_reach = ans + d;
				cnt++;
				flag2 = false;
				break;
			}
		if (flag2)
		{
			cout << -1;
			return 0;
		}
	}
	if (flag)
		cout << cnt + 1;
	else
		cout << -1;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
  string s;
  cin>>s;
  int i=0,j=0;
  while(i<n-1&&j<=n){
    if(s[i]=='1')
    {
      i+=d;
      j++;
    }
    else
      i--;
  }
  if(j>=n)
    cout<<-1;
  else
    cout<<j;
}

#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<utility>
#include<string>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
const int maxn = 300;
int dp[maxn];
int main()
{
    int n,d;
    cin >> n >> d;
    string str;
    cin >>str;
    for(int i = 0 ;i<= 200;++i)dp[i] = 10000;
    dp[0] = 0;

    for(int i = 1 ;i < n;++i)
    {
        if(str[i] == '1')
        {
            int index = i;
            int cnt = 1;
            while(cnt <= d&&index-cnt >=0  )
            {
                if(str[index-cnt] == '1')
                {
                    dp[i] =min(dp[i],dp[index-cnt]+1);
                }
                ++cnt;
            }

        }
    }
    if(dp[n-1]==10000)cout << -1 <<endl;
    else cout << dp[n-1] <<endl;

    return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;

int arr[105], cnt;

int main()
{
	string str;
	int n, m, ans=0;
	cin >> n >> m;
	cin >> str;
	for(int i=0; i<str.length(); ++i){
		if(str[i]=='1') arr[cnt++] = i+1;
	}

	int pos=1, mx=m+pos;
	for(int i=1; i<cnt; ++i){
		if(arr[i]>mx){
			pos=arr[i-1];
			mx=pos+m;
			ans++;
			if(arr[i]>mx){
				cout << -1;
				return 0;
			}
//			cout << pos << endl;
		}
	}

	if(pos < arr[cnt-1]) ans++;
	cout << ans;
	return 0;
 }

#include<bits/stdc++.h>
using namespace std;
int n,d;
string a;
int b[105],s[105];
void bfs(){
	queue<int>q;
	q.push(0);
	b[0]=1;
	s[0]=0;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int i=u+1;i<n;i++){
			if(a[i]=='1'&&i-u<=d&&b[i]==0){
				b[i]=1;
				q.push(i);
				s[i]=s[u]+1;
			}
		}
	}
}
int main(){
    cin>>n>>d;
    cin>>a;
    bfs();
    if(s[n-1]==0)cout<<-1;
    else cout<<s[n-1];
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define lli long long int

#define ulli unsigned long long int

#define Pi 3.14159265358979323846264338327950288419716939937510

int main(){

	ios :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

	int n,d;

	cin>>n>>d;

	vector <int> dp(n+1,1000);

	string s;

	cin>>s;

	s = '*'+s;

	dp[1] = 0;

	for(int i=1; i<=n; i++){

		if(s[i] == '1'){

			for(int j=1; j<=d; j++){

				if(i+j <= n){

					if(s[i+j] == '1' ){

						dp[i+j] = min(dp[i+j],dp[i]+1);
					}
				}
			}
		}
	}

	if(dp[n] == 1000){

		cout<<"-1";
	}

	else{

		cout<<dp[n];
	}
}

#include <bits/stdc++.h>
using namespace std;

void solve(){

int n,k;
cin>>n>>k;
string s;
cin>>s;
long long ans=0;

for(int i=0;i<n;){
    if(i==n-1)
    {
        cout<<ans;
        return;

    }
    if(i+k>=n){
    cout<< ++ans;
    return;
    }else{
        bool found=false;
        for(int j=i+k;j>i;j--)
        {
            if(s.at(j)=='1'){
                ans++;
                i=j;
              //  cout<<i<<" ";
                found=true;
                break;
            }
        }
        if(!found){
            cout<<"-1";
            return;
        }
    }
}

return;
}
int main() {
	int t=1;
//	cin>>t;
	while(t--){
		solve();
		/*if(ans)
		cout<<"YES";
		else
		cout<<"NO";
*/		cout<<"\n";
	}
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool isprime(ll n) {bool flag=true;for(ll i=2; i<=sqrt(n);i++){if(n%i==0){flag=false;break;}}return flag;}
using namespace std;
int flag=0;
int main()
{
	fast
	int n,q,now=0,sum=0;
	cin>>n>>q;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
 		flag=0;
		int k=now+q;
		//cout<<k;
		if(k>n-2)
		{
			sum++;
			flag=1;
			break;
		}
		for(int j=k;j>now;j--)
		{
			if(s[j]=='1')
			{
				now=j;
				sum++;
				flag=1;
				break;
			}
		}
		if(flag==0)
		break;
	}
	if(flag==0)
	cout<<-1;
	else
	cout<<sum;
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    //cout<<"Hello World";
    ll n,k,flag,ans=0;
    cin>>n>>k;
    char a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll i=0;
    while(i<n){
        if(i>=(n-1-k)){
            flag=1;
            goto a;
        }
        for(ll j=k+i;j>i;j--){
            if(a[j]=='1'){
                i=j;
                ans++;
                break;
            }
            if(j==i+1 && a[j]=='0'){
                flag=0;
                goto a;
            }
        }
    }
    a:
    if(flag==0){
        cout<<"-1"<<endl;
    }
    else{
        cout<<ans+1<<endl;
    }
    return 0;
}

#include <iostream>
#include <string.h>
using namespace std;
int n,d,ans=0;
string s;
bool dfs(int step)
{
    int len = s.length();
    if(step==n)
    {
        cout << ans;
        return 1;
    }
    for(int i=d;i>=1;--i)
    {
        if(step<=n && (step+i-1<len) && s[step+i-1]-'0')
        {
            step += i;
            ans++;
            if(dfs(step))
                return 1;
        }
    }
    return 0;
}
int main()
{
    cin >> n >> d;
    cin >> s;
    if(!dfs(1)){cout << -1;return 0;}
    //cout << ans;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,d;
	cin>>n>>d;
	int arr[n]={0};

	getchar();

	string str;

	getline(cin,str);

	for(int i=n-2;i>=0;i--){
		if(str[i]=='1'){
		    int flag=0;
			for(int j=i+d;j>i;j--){
				if(str[j]=='1'){
					if(j-i<=d){
						if(arr[i]==0)
							arr[i]=arr[j]+1;
						else
							arr[i]=min(arr[i],arr[j]+1);

						flag=1;
					}
				}
			}

			if(flag==0)
			    break;
		}
	}

    // for(int i=0;i<n;i++)
    //     cout<<arr[i]<<" ";

        cout<<endl;
	if(arr[0]==0)
		cout<<-1<<endl;
	else
		cout<<arr[0]<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, d;
	cin >> n >> d;
	string s;
	cin >> s;
	s='k'+s;

	#define INF 1e9
	vector<int> dp(n+1, INF);
	dp[1]=0;
	for(int i=1; i<=n; i++){
		if(s[i]=='0') dp[i]=INF;
		else{
			for(int j=i-1; j>=max(1, i-d); j--){
				dp[i]=min(dp[i], dp[j]+1);
			}
		}
	}
	cout << (dp[n]==INF? -1: dp[n]);
}

#include <iostream>
using namespace std;
int main()
{
    int i,n,d,j,s,sum=0;
    char a[100];
    cin >> n >> d;
    for(i=0;i<n;i++)
        cin >> a[i];
    for(i=0;i<n;)
    {
        s=0;
        for(j=1;j<=d;j++)
            if(a[j+i]=='1'&&j+i<n) s=j;
        if(s==0) break;
        else {i=i+s;sum++;}
    }
    if(i<n-1) sum=-1;
    cout << sum << endl;
    return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    string s;
    cin>>s;
    int temp=0;
    int flag=0;
    int ans=0;
    int i;
    for(i=k;i<n;i+=k)
    {
    	if(s[i]=='1')
    	{
    		ans++;
    	  continue;
       }
    	while(s[i]!='1')
    	{
    		i--;
		}
		if(i<=temp)
		{
			flag=-1;
//			cout<<-1<<endl;
			break;
		}
		else
		{
			temp=i;
			ans++;
			continue;
		}
		ans++;
	}
	if(i-k!=n-1)
	ans++;
	if(flag==-1)
	cout<<-1<<endl;
	else
	cout<<ans<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int j,i,c=0,n,d;
    cin>>n>>d;
    i=n-1;
    string arr;cin>>arr;
    while(i>0)
    {
    for(j=d;j>=1;j--)
        {if(arr[i-j]=='1')
            {c++;i-=j;break;}
        }
        if(j==0){cout<<-1;return 0;}
    }
    cout<<((c==0)?-1:c);
}

#include<bits/stdc++.h>
#define ll long long
#define vi vector<ll>
#define pb(x) push_back(x)
#define mp make_pair
#define rep(i,x,y) for(i=x;i<y;i++)
#define lb(arr,n,x) lower_bound(arr,arr+n,x)
#define ub(arr,n,x) upper_bound(arr,arr+n,x)
#define precise(x,y) fixed<<setprecision(y)<<x
#define fi first
#define se second
#define mod 1000000007
using namespace std;
const ll N=200005;
vector<ll> adj[N];
ll vis[N]={0};
ll ans=0;
int main()
{
   int n,d;
   cin>>n>>d;
   string s;
   cin>>s;
   int i,j;
   int dp[n];
   memset(dp,-1,sizeof(dp));
   dp[0]=0;
   for(i=1;i<n;i++)
   {
       if(s[i]=='1')
       {
        for(j=max(0,i-d);j<i;j++)
           {
               if(s[j]=='1'&&dp[j]!=-1)
               {
                   dp[i]=dp[j]+1;
                   break;
               }
           }
       }
   }
   cout<<dp[n-1];
}

#include<iostream>
using namespace std;

long long n,d,nr=0,x,ok=1;
char a[110];
int main(){
    cin>>n>>d;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }

    int i=1;

    while(i!=n)
    {
        x=i;
        i=i+d;
        while(a[i]!='1'){
            i--;
        }
        if(i==x)
        {
            ok=0;
            cout<<"-1";
            break;
        }

        nr++;

    }
    if(ok==1)
        cout<<nr;

}

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <set>
#include <vector>

using namespace std;
typedef int32_t i;
#define endl '\n'
int main()
{
    i n,d;
    cin>>n>>d;
    string s;
    cin>>s;
    i a=0;
    i p=1;
    while(p<n){
        for(i q=d;q>=0;q--){
                        if(q==0){
                cout<<-1;
                return 0;
            }
            if(p+q-1<n&&s[p+q-1]=='1'){
                p+=q;
                a++;
                break;
            }

        }
    }
    cout<<a;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

int n, d;
vector<bool> v;
vector<int> DP;

int f(int i)
{
	if(DP[i] != -1) return DP[i];
	int min = 10000;
	for(int o = i+1; o <= i+d && o < n; o++)
		if(v[o]) min = std::min(f(o)+1,min);
	return DP[i] = min;
}

int main()
{

	cin >> n >> d;
	v.resize(n);
	DP.resize(n);
	for(int i = 0; i < n; i++)
	{
		char a;
		cin >> a;
		v[i] = (a == '1');
		DP[i] = -1;
	}
	DP[n-1] = 0;

	int resp = f(0);
	if(resp >= 10000)
		cout << -1 << endl;
	else
		cout << f(0)<< endl;

	return 0;
}

#include<stdio.h>
#include<iostream>
#include<cstring>
#include<queue>
#include<stack>
#include<set>
using namespace std;

const long long inf=10000000000010;

int n,d;
long long dp[1000];
char a[1000];
bool vis[1000];

int main()
{
	scanf("%d%d%s",&n,&d,a);
	for(register int i=1;i<=n;++i)vis[i]=a[i-1]=='1';
	for(register int i=1;i<=n+1;++i)dp[i]=inf;
	dp[1]=0;vis[1]=true;
	for(register int i=1;i<=n;++i)
		if(vis[i])
			for(register int j=1;j<=d;++j)
				dp[i+j]=min(dp[i+j],dp[i]+1);
	if(dp[n]<inf)printf("%lld\n",dp[n]);
	else printf("-1\n");
	return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  int n, d;
  cin >> n >> d;
  string str;
  cin >> str;

  vector<int> dp(n, n + 10);
  for (int i = 0; i <= d; i++) {
    if (str[i] == '0') continue;
    dp[i] = 1;
  }

  for (int i = d + 1; i < n; i++) {
    if (str[i] == '0') continue;
    for (int j = 0; j < d; j++) {
      dp[i] = min(dp[i], dp[i - j - 1] + 1);
    }
  }

  if (dp.back() == n + 10)
    cout << -1 << endl;
  else
    cout << dp.back() << endl;
  return 0;
}

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define fs first
#define sc second
#define descorder greater<int>() //for descending sort
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

string blank = "";

string path = "";
int def;
int mem[100];
bool fou[100] = {false};
int solve(int n, int d){
	int best = 1e9;
	if(n < 0) return 1e9;
	if(n == 0) return 0;
	if(path[n] == '0') return 1e9;
	if(fou[n]) return mem[n];
	for(int i = d; i >=1; i--){
		int res = solve(n - i, d);
		best = min(best, res+1);
	}
	mem[n] = best;
	fou[n] = true;
	return (best == 1e9) ? ((n == def-1) ? -1 : 1e9) : best;
}

int main(){
// 	freopen("input.txt", "r",stdin);
// 	freopen("output.txt", "w",stdout);
	int n , d;
	cin >> n >> d;
	def = n;
	cin >> path;
	cout << solve(n-1, d);
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

const int MAXN=1e2+7;
//const int DIRX[]=;
//const int DIRY[]=;
//const int INF=0x3f3f3f3f;

int n,d;
char str[MAXN];
int step;
int cnt;
bool flag;

int main()
{
	scanf("%d%d",&n,&d);
	scanf("%s",str);
	step=0;
	flag=true;
	if(d==n-1)
	{
		step=0;
	}
	else if(d==1)
	{
		for(int i=0;i<n;i++)
		{
			if(str[i]=='0')
			{
				flag=false;
				break;
			}
		}
		step=n-2;
	}
	else
	{
		for(int i=0;i<n-d-1;)
		{

			int j=i+d;
			for(j;j>i;j--)
			{
				if(str[j]=='1')
				{
					i=j;
					//cout<<i<<endl;
					step++;
					break;
				}
				if(j==i+1&&str[j]=='0')
				{
					flag=false;
					break;
				}
			}
			if(flag==false)break;
			//if(i==n-1)break;
		}
	}

	if(flag)printf("%d\n",step+1);
	else printf("-1\n");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, d, res = 0, no = 0;
	string s;
	cin >> n >> d;
	cin >> s;

	while (no<n-1) {
		int i = d;
		for (; i >= 1; i--) {
			if (no + i>n - 1 || s[no + i] != '1')
				continue;
			else {
				no = no + i;
				res++;
				break;
			}
		}
		if (i == 0) {

			cout << "-1" << endl;
			return 0;
		}
	}
	cout << res;
	return 0;
}

#include<cstdio>
#include<iostream>
using namespace std;

int n,d;
int a[105] = {};
int calc(int t)
{
	if (t + d >= n)
		return 1;
	else
	{
		int pos = -1;
		for (int i = t + d;i > t;i--)
		{
			if (a[i] == 1)
			{
				pos = i;
				break;
			}
		}
		if (pos == -1)
		{
			return -1;
		}
		else
		{
			int ans = calc(pos);
			if (ans == -1)
			{
				return -1;
			}
			else
			{
				return ans + 1;
			}
		}
	}
}

int main()
{
	cin >> n >> d;
	for (int i = 1;i <= n;i++)
	{
		char c;
		cin >> c;
		a[i] = int(c - '0');
	}
	cout << calc(1) << endl;
	return 0;
}

	// I can't tell you what it really is,
	// I can only tell you what it feels like.
	#include "bits/stdc++.h"
	using namespace std;

	#define int long long
	#define F first
	#define S second
	#define rep(i,a,n) for (int i = a; i <= n; ++i)
	#define fo(i, n)   for (int i = 1; i <= n; ++i)
	#define all(v)  v.begin(), v.end()
	#define pb push_back
	#define P pair < int, int >
	#define fast  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

	const int N = 1e2 + 5;
	int h[N];
	signed main(){
	   fast;
	   int n, d, k;
	   fill(h, h + N, 105);
	   cin >> n >> d;
	   string s;
	   cin >> s;
	   s = '!' + s;
	   h[1] = 0;
	   for(int i = 2;i <= d; ++i)
	   	h[i] = ((s[i] - '0') ? 1 : -1);

	   	for(int i = d + 1; i <= n; ++i) {
	   		k = d;
	   		if(s[i] == '0') {
	   			h[i] = -1;
	   			continue;
	   		}
	   		for(int j = i - 1; k-- && j > 0; j -= 1) {
	   			if(h[j] < 0)
	   				continue;
	   			h[i] = min(h[i], 1 + h[j]);
	   		}
	   	}
	   	// fo(i, n)
	   	// 	cout << h[i] << ' ';
	   	cout << ((h[n] == N) ? -1 : h[n]);

		return 0;
	}

#include<bits/stdc++.h>
using namespace std;
#define N 105
#define inf 0x3f3f3f3f
using namespace std;

int n,d,cnt;
char a[N];
int dist[N],head[N];
bool vis[N];
struct Edge{
    int v,nxt;
}edge[N*N];

inline void add(int u,int v)
{
    cnt++;
    edge[cnt].v=v;
    edge[cnt].nxt=head[u];
    head[u]=cnt;
}
int spfa()
{
    for(int i=1;i<=n;i++)
        dist[i]=inf;
    queue<int> q;
    dist[1]=0;
    vis[1]=1;
    q.push(1);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int v,w,i=head[u];i;i=edge[i].nxt)
        {
            v=edge[i].v;
            w=dist[u]+1;
            if(dist[v]>w)
            {
                dist[v]=w;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
    if(dist[n]==inf)
        return -1;
    else
        return dist[n];
}
int main()
{
    scanf("%d%d",&n,&d);
    while(getchar()!='\n');
    for(int i=1;i<=n;i++)
        a[i]=getchar();
    for(int i=1;i<=n;i++)
        if(a[i]=='1')
            for(int j=1;j<=d&&i+j<=n;j++)
                if(a[j+i]=='1')
                    add(i,i+j);
    cout<<spfa()<<endl;
}

/*
* @Author: _dp95
* @Date:   2019-01-14 23:17:10
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end()
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

int dp[ MAX ] ;

int main( ){
    timesaver ;
    for( int i = 0 ; i < MAX ; i++ )
        dp[ i ] = MAX ;
    dp[ 0 ] = 0 ;
    int n, d ;
    string s ;
    cin >> n >> d >> s ;
    for( int i = 0 ; i < n ; i++ ){
        int lvl = MAX ;
        for( int j = max( 0, i - d ) ; j < i ; j++ )
            if( s[ j ] == '1' )
                lvl = min( lvl, dp[ j ] ) ;
        dp[ i ] = min( dp[ i ], lvl + 1 ) ;
    }
    if( dp[ n - 1 ] == MAX )
        cout << -1 << nl ;
    else
        cout << dp[ n - 1 ] << nl ;
}

/*
* @Author: _dp95
* @Date:   2019-01-14 23:24:28
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end()
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

int dp[ MAX ] ;

int main( ){
    timesaver ;
    for( int i = 0 ; i < MAX ; i++ ){
        dp[ i ] = MAX ;
    }
    dp[ 0 ] = 0 ;
    int n, d ;
    string s ;
    cin >> n >> d >> s ;
    for( int i = 0 ; i < n ; i++ ){
        for( int j = 1 ; j <= d and i - j >= 0 ; j++ )
            if( s[ i - j ] != '0' )
                dp[ i ] = min( dp[ i ], 1 + dp[ i - j ] ) ;
    }
    if( dp[ n - 1 ] == MAX )
        cout << -1 << nl ;
    else
        cout << dp[ n - 1 ] << nl ;
}

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL_DEFINE
	#include "DebugUtils.cpp"
#endif

using Long = long long;
using LD = long double;
using IntPair = pair<int, int>;
using IntVector = vector<int>;

template <class T>              void read(T& x)          { cin >> x; }
template <class T, class... U>  void read(T& t, U&... u) { read(t); read(u...); }
template <class T>              void reada(T* a, int n)  { for (int i = 0; i < n; ++i) read(a[i]); }

template <class T = bool>      bool println()            { return !!(cout << endl); }
template <class T>             bool print(T t)           { return !!(cout << t); }
template <class T>             bool println(T t)         { print(t); return println(); }
template <class T, class... U> bool print(T t, U... u)   { print(t); print(' '); return print(u...); }
template <class T, class... U> bool println(T t, U... u) { print(t); print(' '); return println(u...); }

template <class T, class U>             auto maxx(T t, U u)         -> typename common_type<T, U>::type       { return (t > u) ? t : u; }
template <class T, class U, class... V> auto maxx(T t, U u, V... v) -> typename common_type<T, U, V...>::type { return maxx(maxx(t, u), v...); }
template <class T, class U>             auto minn(T t, U u)         -> typename common_type<T, U>::type       { return (t < u) ? t : u; }
template <class T, class U, class... V> auto minn(T t, U u, V... v) -> typename common_type<T, U, V...>::type { return minn(minn(t, u), v...); }

template <class T> int maxIndex(T* x, T* y) { return max_element(x, y) - x; }
template <class T> int minIndex(T* x, T* y) { return min_element(x, y) - x; }
template <class T> T maxa(T* x, T* y) { return *max_element(x, y); }
template <class T> T mina(T* x, T* y) { return *min_element(x, y); }

template <class T, class U> bool minimize(T& t, U u) { if (u < t)  { t = u; return 1; } return 0; }
template <class T, class U> bool maximize(T& t, U u) { if (u > t)  { t = u; return 1; } return 0; }
template <class T, class U, class... V> bool minimize(T& t, U u, V... v) { if (auto m = minn(u, v...); m < t)  { t = m; return 1; } return 0; }
template <class T, class U, class... V> bool maximize(T& t, U u, V... v) { if (auto m = maxx(u, v...); m > t)  { t = m; return 1; } return 0; }

template <class T, class U> bool contains(U x, U y, T z) { return find(x, y, z) != y; }
template <class T, class U> int indexOf(U x, U y, T z)   { return find(x, y, z) - x; }

template <class T> T powi(T x, int y) { T ans = 1; while (y > 0) { if (y & 1) ans *= x; y >>= 1; if (y > 0) x *= x; } return ans; }
template <class T> T sqr(T x)         { return x * x; }

mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<Long> uid(0L);
Long randInt(Long x, Long y) { return (uid(mrand) % (y - x + 1)) + x; } // [x, y] inclusive

#ifdef LOCAL_DEFINE
	Long ITR = 1e8; // nil; (for no infinite loop)
#else
	#define tr(x...) 0;
	#define nil 0;
	#define pr(x...) 0;
	#define prl(x...) 0;
	#define pra(x...) 0; // pra(a, n)
	#define pr2d(x...) 0; // pr2d<M, N>(a, -2) or (a, 3, 4)
	#define ts(x...) "";
#endif

const int INF = 1e9;

namespace Solver {

	const int N = 1e6;
	int testCases = 1;
	int a[N], dp[N];

	bool solve(int testNumber) {nil
		int n, d; string s; read(n, d, s);
		fill_n(dp, n, INF);
		dp[0] = 0;
		for (int i = 1; i < n; ++i) {
			if (s[i] == '0') continue;
			for (int j = 1; j <= min(d, i); ++j) {
				if (s[i - j] == '0') continue;
				minimize(dp[i], 1 + dp[i - j]);
				nil;
			}
		}
		return println(dp[n - 1] < INF ? dp[n - 1] : -1);
	}

	void solve() {
		#ifdef LOCAL_DEFINE
			freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout); freopen("output.txt", "a", stderr); read(testCases);
		#else
			ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
		#endif
		// read(testCases);
		for (int i = 1; i <= testCases; ++i) solve(i);
	}

};

int main() {
	auto t1 = chrono::high_resolution_clock::now(); Solver::solve(); auto t2 = chrono::high_resolution_clock::now(); chrono::duration<double> t = t2 - t1;
	cerr << "\nTime taken: " << fixed << setprecision(5) << t.count() << "s\n" << endl; cout << endl;
	return 0;
}

#include "stdio.h"
#include "stdlib.h"
#include "string.h"

int main()
{
	int n, d;

	while (scanf_s("%d%d", &n, &d) != EOF)
	{
		char lily[110];
		memset(lily, '0', sizeof(lily));
		scanf_s("%s", lily, 110);

		int count = 0, flag = 1;
		int i, k;
		for (i = 0; i < n - 1;) {
			int ii = i;
			for (k = i + d; k > i;) {
				if (lily[k] == '1') {
					count++;
					i = k;
					break;
				}
				else
					k--;
			}
			if (k == ii) {
				flag = 0;
				break;
			}
		}

		if (flag)
			printf("%d\n", count);
		else
			printf("-1\n");
	}

	return 0;
}

#include <iostream>
#include <vector>
#include <cstring>
#include <stack>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <functional>
#include <cmath>

#define ll long long
#define mp make_pair
#define pb push_back
#define pi 3.14159
//#define mod 1000000007
const int mod=1000000007;
const int inf=1e9;
using namespace std;
int dp[1002];
int ncr[1002][1002];

int main()
{
    int n,d,i,j;
    string s;
   cin>>n>>d;
   for(i=0;i<n+2;i++)
    dp[i]=inf;
   cin>>s;
   dp[0]=0;
   for(i=0;i<n;i++)
   {
        if(s[i]=='1')
        {
            for(j=1;j<=d && i+j<n;j++)
            {
                if(s[i+j]=='1')
                {
                    dp[i+j]=min(dp[i+j],dp[i]+1);
                }
            }
        }
   }
   if(dp[n-1]==inf)
    cout<<"-1";
   else cout<<dp[n-1];

}

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <string>
using namespace std;
string tale(string s2,int n,int d)
{
    string s;
    for(int i=n;i<n+d;i++)
    s+=s2[i];
    return s;
}

int main()
{
    int n,d;
    cin>>n>>d;
    string s;
    cin>>s;
    string s2;
    for(int i=0;i<d;i++)
    s2+='0';
    for(int i=0;i<s.length()-d;i++)
    {
        if(tale(s,i,d)==s2)
        {
           cout<<-1;
           return 0;
        }
       // cout<<tale(s,i,d)<<"  "<<s2<<"   ";
    }
    int k,l=0;
    for(int i=0;i<=s.length();i+=k)
    {
        for(int j=d;j>0;j--)
        {
            if(j+i<s.length())
            {if(j+i<s.length() && s[j+i]=='1')
            {
                k=j;
               // cout<<k<<" ";
                l+=1;//cout<<l<<" ";
                break;
            }}
        }
    }
    cout<<l;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int indix=0;
int sum=0;
int minn=101;

int main()
{
   int n,x,i;
   string s;
   cin>>n>>x;
   cin>>s;
   int c=x-1;
   int g=0;
   for(i=0;i<s.length();i+=g)
   {
       if(i==s.length()-1)
       {
           break;
       }
       g=0;
       c=x-1;
       if(s[i+x]=='1')
       {
           sum++;
           g+=x;

       }
       else
       {
           while(c!=0)
           {
               if(s[i+c]=='1')
               {
                   sum++;
                   g+=c;
                   break;
               }
               c--;
           }
           if(c==0)
           {
               cout<<"-1";
               return 0;
           }
       }
   }
   cout<<sum;

return 0;
}

#include<bits/stdc++.h>
using namespace std;

int dp[105];
int main()
{int n,d;
cin>>n>>d;
string a;
cin>>a;

memset(dp,-1,sizeof(dp));
dp[0]=0;
for(int i=1;i<n;i++)
{
if(a[i]=='1')
{
int prev;
for(int j=max(i-d,0);j<i;j++)
{
if(a[j]=='1'||j==0)
{

if(dp[i]!=-1)
dp[i]=min(dp[i],dp[j]+1);
else dp[i]=dp[j]+1;

}
}
}
}

if(dp[n-1]==-1)cout<<-1;
else cout<<dp[n-1];
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,i;
    cin>>n>>d;
    string s;
    cin>>s;
    int pr=0;
    int pt=d;
    n--;
    int c=0;

    while(1)
    {
        if(pt>=n)
        {

            cout<<c<<endl;
            return 0;
        }
        else
        {

            if(s[pt]=='1')
            {
                c++;
                pr=pt-1;
                pt+=d;
                if(pt>=n)
                    c++;

            }
            else
            {
                int r1=0;
                int f;
                for(i=pr+1; i<pr+d; i++)
                {
                    if(s[i]=='1')
                    {
                        f=i;
                        r1++;
                    }
                }
                if(r1==0)
                {
                    cout<<-1<<endl;
                    return 0;
                }
                else
                {
                    pr=pt-1;
                    pt=f+d;
                    c++;
                    if(pt>=n)
                        c++;

                }

            }
        }
    }

}

#include <bits/stdc++.h>
using namespace std;

#define ll long long

void solve(){
	ll n,d;
	cin>>n>>d;
	string s;
	cin>>s;
	int jump = 0;
	int curind = 0;
	int dcopy = d;
	while(1){
		int index = -1;
		for(int i=curind+1;i<=d && i<n;i++){
			if(s[i] == '1'){
				index = max(index,i);
				cout<<index<<endl;
			}
		}
		if(index == -1){
			cout<<"-1"<<endl;
			return;
		}
		else{
			jump++;
			d = index + dcopy;
			curind = index;
			cout<<"-------------------"<<jump<<endl;
		}
		if(index == n - 1){
			cout<<jump<<endl;
			return;
		}
	}
}
int main(){
	int test;
	// cin>>test;
	// while(test--)
	solve();
	return 0;
}

#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{

int n;
int m;
cin>>n;
cin>>m;
string s;
cin>>s;
int dp[n];
memset(dp,10000,sizeof(dp));
dp[0]=0;
for(int i=0;i<n;i++)
{
    if(s[i]=='1')
    {
      for(int j=0;j<=m;j++)
      {
          if(i+j<n&&s[i+j]=='1')
          {
              dp[i+j]=min(dp[i+j],dp[i]+1);
          }

      }
    }
}
if(dp[n-1]==10e3) cout<<"-1"<<endl;
else cout<<dp[n-1]<<endl;
	return 0;
}

/*
* @Author: _dp95
* @Date:   2019-01-14 23:22:08
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end()
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

int dp[ MAX ] ;

int main( ){
    timesaver ;
    for( int i = 0 ; i < MAX ; i++ ){
        dp[ i ] = MAX ;
    }
    dp[ 0 ] = 0 ;
    int n, d ;
    string s ;
    cin >> n >> d >> s ;
    for( int i = 0 ; i < n ; i++ ){
        for( int j = 1 ; j <= d and i - j >= 0 and s[ i - j ] ; j++ )
            dp[ i ] = min( dp[ i ], 1 + dp[ i - j ] ) ;
    }
    if( dp[ n - 1 ] == MAX )
        cout << -1 << nl ;
    else
        cout << dp[ n - 1 ] << nl ;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	int n,m,d;
	cin>>n>>d;
	string a;
	int b[101];
	cin>>a;
	for(int i=0;i<=n;i++){
		b[i]=110;
	}
	b[0]=0;
	for(int i=1;i<n;i++){
		int min=101;
		for(int j=i-d;j<i;j++){
			if(j<0)continue;
			if(b[j]<min)min=b[j];
		}
		if(a[i]=='1')b[i]=min+1;
	}

	//cout<<endl;
	if(b[n-1]==110)
		cout<<-1;
	else
		cout<<b[n-1];

}

#include<bits/stdc++.h>
using namespace std;
const int N=120;

inline int read()
{
	char c;int f=1;
	while((c=getchar())<'0'||c>'9')
		if(c=='-') f=-1;
	int x=c-48;
	while((c=getchar())>='0'&&c<='9')
		x=(x<<1)+(x<<3)+c-48;
	return x*f;
}
int n,d,now=1,p[N],cnt;
string s;
int main()
{
	n=read(),d=read();
	cin>>s;
	for(int i=0;i<s.size();i++) p[i+1]=s[i]-'0';
	while(now!=n)
	{
		for(int i=d;i>=1;i--)
		{
			if(i==1&&!p[now+1])
			{
				cout<<-1<<endl;
				return 0;
			}
			if(p[now+i])
			{
				now+=i,cnt++;
				break;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
int main() {
    int n, d;
    cin >> n >> d;
    string path;
    int lily;
    cin >> path;
    int n_jumps = 0;
    int k = d;
    int s = 0;
    bool flag = true;
    int l;
    while(true) {
        flag = true;
        for(int i=k; i>s; i--) {
            if(path[i] == '1') {
                n_jumps++;
                flag = false;
                l = i;
                break;
            }
        }
        s = l;
        k = l+d;

        if(flag) {
            cout << -1;
            exit(0);
        }
        if(k >= n-1) {
            n_jumps++;
            break;
        }

    }
    cout << n_jumps;
}

#include <iostream>   // std::cout
#include <string>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, d, count=0, temp=0;
    cin>>n>>d;
    cin.ignore();
    char a[n]; int b[n], store[150];
    memset(store,0,sizeof(store));
    cin.getline(a,sizeof(a)+1);
    cout<<(a)<<endl;
    for (int i=0; i<strlen(a); i++)
        {
            b[i]= ((int)(a[i])) - 48;
            //cout<<b[i]<<endl;
            if (b[i]==1)
            {
                store[i]++;
            }
        }
        temp+=d;
    while (temp<n && temp>0)
    {
        if (store[temp]>0)
        {
            count++;
            temp+=d;
            if(temp>=n)
                {
                    if (store[n-1]>0)
                    {
                        count++;
                        break;
                    }
                    else break;
                }
        }
        else temp--;

    }
    if (count>0)
    cout<<count<<endl;
    else cout<<-1<<endl;
}

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <string>
using namespace std;
string tale(string s2,int n,int d)
{
    string s;
    for(int i=n;i<n+d;i++)
    s+=s2[i];
    return s;
}

int main()
{
    int n,d;
    cin>>n>>d;
    string s;
    cin>>s;
    string s2;
    for(int i=0;i<d;i++)
    s2+='0';
    for(int i=0;i<s.length()-d;i++)
    {
        if(tale(s,i,d)==s2)
        {
           cout<<-1;
           return 0;
        }
       // cout<<tale(s,i,d)<<"  "<<s2<<"   ";
    }
    int k,l=0;
    for(int i=0;i<=s.length()-k;i=i+k)
    {
        for(int j=d;j>0;j--)
        {
            if(s[j]=='1')
            {
                k=j;
                l+=1;
                break;
            }
        }
    }
    cout<<l;
}

#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int main(){
	int n,d,p,step=0;
	bool flag;
	string a;
	cin>>n>>d;
	cin>>a;
	n--;
	while(p!=n){
		flag=0;
		for(int i=p+d;i>=p+1;--i)
	  {
		if(a[i]=='1')
		{
			p=i;
			flag=1;
			break;
		}
		if(flag==0)
		{
			cout<<"-1"<<endl;
			return 0;
		}
		else step++;
	  }
	}
	cout<<step<<endl;
	return 0;

}

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,d;
    cin>>n>>d;
    string s;
    cin>>s;
    int zero=1,county=0;;
    for(int i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1]&&s[i]=='0')
            zero++;
        else
        {
            if(zero>county)
                county=zero;
            zero=1;
        }
    }
    if(county>=d)
        cout<<-1;
    else
    {
        int j;
    int step=0,a=d;
    for(int i=0;i<n-4;i++)
    {
        for(j=a;j>=0;j--)
        {
            if(s[j]=='1')
            {
                step++;
                a=j+d;
                break;
            }
        }
        if(j==n-1)
            break;
    }
    cout<<step;
    }
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n,d,b=0;
    string a;
    cin >>n>>d>>a;
    for (int i=0,j; i<a.size();)
    {
        if (i+d >= a.size())
        {
            ++b;
            break;
        }
        if (a[i+d] == '1') i+=d,++b;
        else
        {
            for (j=i+d; i<j && a[j] == '0'; --j);
            if (i == j)
            {
                cout <<"-1";
                return 0;
            }
            else i=j,++b;
        }
    }
    cout <<b;
}

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <string>
using namespace std;
string tale(string s2,int n,int d)
{
    string s;
    for(int i=n;i<n+d;i++)
    s+=s2[i];
    return s;
}

int main()
{
    int n,d;
    cin>>n>>d;
    string s;
    cin>>s;
    string s2;
    for(int i=0;i<d;i++)
    s2+='0';
    for(int i=0;i<s.length()-d;i++)
    {
        if(tale(s,i,d)==s2)
        {
           cout<<-1;
           return 0;
        }
       // cout<<tale(s,i,d)<<"  "<<s2<<"   ";
    }
    int k,l=0;
    for(int i=0;i<=s.length();i+=k)
    {
        for(int j=d;j>0;j--)
        {
            if(j+i<s.length())
            {if(j+i<s.length() && s[j+i]=='1')
            {
                k=j;
                cout<<k<<" ";
               // l+=1;cout<<l<<" ";
                break;
            }}
        }
    }
    cout<<l;
}

#include <iostream>
#include <string.h>
using namespace std;

int search(int a[],int b,int n){
    int flag=0;
    for(int i=1;i<n;i++){
        if(a[i]==b){
        flag=1;
        break;
        }

    }

    if(flag==1)
    return 1;
    else
    return 0;

}

int main(){

    int n,d,j=1,count=0,k=1,m;
    cin>>n>>d;
    string s;
    int c[n];
    s.resize(n*sizeof(int));
    for(int i=1;i<=n;i++)
    cin>>s[i];

 while(j<=n){
     if(s[j]=='1'){
         c[k]=j;
         k++;
     }

j++;

}
j=1;
m=d;
while(m>=1){
int r=search(c,m+j,k);
if(r==1){
    count++;
    j=j+m;
    m=d;
}

else
m--;
}

if(count==0)
cout<<-1<<" ";
else
cout<<count;

}

#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mP              make_pair
#define PI              3.1415926535897932384626
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define i(x)            ll x; cin>>x;
#define fr(i,s,e)       for(ll i=s;i<e;i++)
#define up(su)          transform(su.begin(), su.end(), su.begin(), ::toupper);
#define lo(su)          transform(su.begin(), su.end(), su.begin(), ::tolower);
#define all(x)          x.begin(),x.end()
#define N               100001

void c_h_g()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}

int main()
{
    c_h_g();

    i(n) i(d)
    string s; cin>>s;
    ll dp[n+1];
    ll cnt = 0;
    dp[0] = 0;
    fr(i,1,n){
    	if(s[i] == '1'){
    		dp[i] = i;
    		cnt = i;
    	}
    	else{
    		dp[i] = cnt;
    	}
    }
    int flag = 0;
    ll i = d;
    ll ans = 0;
    while(i<n){
    	ll z= dp[i];
    	ans++;
    	if(i == z+d){
    		cout<<-1<<endl;
    		flag = 1;
    		break;
    	}
    	i = z + d;
    	if(i>=n-1){
    		ans++;
    		break;
    	}
    }
    if(flag == 0) cout<<ans;

    return 0;
}

#include<iostream>
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n,d;
	char c;
	cin>>n>>d;
	int i=d;
	string s;
	cin>>s;
	int jmp1=0;
	int pre=0;
	while(i!=pre && pre!=n-1){
		if(i<n && s[i]=='1'){
			//cout<<i<<endl;
			jmp1++;
			pre=i;
			i=i+d;
		}
		else{
			i--;
		}
	}
	if(i!=n-1)
		cout<<-1;
	else
		cout<<jmp1;
}

#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
  #define pb push_back
#define f first
#define s second
  #define MAXN 100005
using namespace std;
// iterative one
int dp[MAXN];
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int d;
	cin>>d;
	string s; cin>>s;
	dp[0]=0;
	mem(dp,1e8);
	for(int i=0; i<n; i++) {
		if(s[i]=='0') continue;
		for(int j=1; j<=d; j++) {
			if(i-j>=0) {
				dp[i]=min(dp[i],1+dp[i-j]);
			}
		}
	}
	if(dp[n-1]>=1e8) dp[n-1]=-1;
	cout<<dp[n-1]<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int n,d,i,k,j;
string s;

int main() {
	cin >> n >> d;
	cin >> s;
	k=0;j=0;
	for(i=d;i>=1;i--){
	    if(s[k+i]=='1'){
	        k=k+i;j++;
	        i=d+1;
	    }
	    if(s[k+i]=='0' && i==1){
	        j=-1;break;
	    }
	}
	cout << j;
	return 0;
}

// ConsoleApplication49.cpp: ���������� ����� ����� ��� ����������� ����������.
//
//#include "stdafx.h"
#include <iostream>

using namespace std;

int main() {
	int n, d, pos = 0, count = 0;
	int oX[100];
	bool exit = false;
	long long x;
	cin >> n >> d;
	cin >> x;
	for (int i = n - 1; i >= 0; i--) {
		oX[i] = x % 10;
		x = x / 10;
	}
	while (pos + 1 != n) {
		for (int j = pos + d; j >= pos; j--) {
			if (oX[j] == 1 && j != pos) {
				pos = j;
				count++;
				break;
			}
			if (j == pos) {
				exit = true;
				break;
			}
			else {
				continue;
			}
		}
		if (exit == true) {
			break;
		}
	}
	if (exit != true) {
		cout << count;
	}
	else {
		cout << "-1";
	}
}

#include<bits/stdc++.h>

using namespace std;
//int next,cnt;
//    now=0;

int check( string arr, int nw, int d)
{
//    cout<<"KMFDKF"<<now<<"MF:"<<d<<endl;
//    cout<<arr[now+d]<<endl;
    if(d==0)
    {
        return -1;
    }
    if(arr[nw+d]=='1')
    {
//        cout<<arr<<endl;
//        cout<<now<<" "<<d<<endl;
//        cout<<arr[now+d]<<endl;
        return d;
    }

    else
        return check(arr, nw, d-1);

}

//void go(string s, int d)
//{
//    next=check(s,d);
//    if(next==-1)
//    {
//        cout<<-1<<endl;
//        return;
//    }
//    cnt++;
//    now=now+next;
//    if(now>=)
//    go(s,d);
//}

int main()
{
    int n,d,now=0,next,cnt=0;
    cin>>n>>d;
    string s;
    cin>>s;
//    cout<<s[3]<<endl;
//    go(s,d)
    while(1)
    {
        next=check(s,now,d);
//        cout<<"NEXT"<<next;
        if(next==-1)
        {
            cout<<-1<<endl;
            return 0;
        }
        cnt++;
//        cout<<"now: "<<now<<"next; "<<next<<"now+next"<<now+next<<endl;

        now=now+next;
        if(now==n-1)
        {
            cout<<cnt<<endl;
            return 0;

        }
//        cout<<"haahaahaa"<<endl;
    }

//    cout<<next<<endl;

    return 0;
}

#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
    int n,d;
    cin>>n>>d;
    string str;
    cin>>str;
    int arr[n];
    int l=0;
    for(int i=0;i<n;i++){
        if(str[i]=='1'){
            arr[l]=i+1;
            l++;
        }
    }

    int cj=0;
    int nj=0;
    while(cj<=l){
     int lj=cj;
     while(cj<=l && (arr[cj+1]-arr[lj])<=d){
        cj=cj+1;
     }
     if(cj==lj){
        nj=-1;
        break;
     }
     if(cj<=l){
        nj+=1;
     }
    }
    cout<<nj<<"\n";
return 0;}

#include<bits/stdc++.h>
using namespace std;
main()
{
    bool c = false;
    int n,d,i,j,check=0,count=0;
    scanf("%d %d",&n,&d);
    string s;
    vector<int> v;
    vector<int> :: iterator it;
    cin >> s;
    for(i=0;i<s.size();++i){
        v.push_back(s[i]%2);
    }
    it = v.begin();
    if(*it!=1||*(v.end()-1)!=1){
        printf("-1");
    }
    else{
        while(it!=v.end()){
            c = false;
            for(i=1;i<=d;++i){
                //printf("index%d=%d\n",it-v.begin()+i,*(it+i));
                if(*(it+i)==1){
                    check = it+i-v.begin();
                    c = true;
                }
            }
            if(!c) break;
            else{
                it = check+v.begin();
                count++;
                //printf("%d\n",count);
            }
            if(it==v.end()-1) break;
        }
        if(count){
            printf("%d",count);
        }
        else{
            printf("-1");
        }

    }
}
/**
8 4
11100101
3
8 4
10010011
2
*/

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n , d , prev_one_index = 0 ; cin>> n >> d ;
    string s ; cin>> s ;
    for( int i=0 ; i< n ; i++){
        if( i==0 ) {
            prev_one_index= i ;
        }
        else if( s[i]=='1' and i>0 ) {
            if( i-prev_one_index  > d ){
                cout<<"-1\n"; return 0;
            }
            else
                prev_one_index= i ;
        }
    }
    if( s[n-1]=='0' ){
        cout<<"-1\n"; return 0;
    }

    int step=0 ;
    for( int i= 1 ; i< n ; i++){
        if( s[i-1]=='1' and s[i]=='0') step++;
    }

    cout<< step+1 << endl;
    return 0;

}

#include <cmath>
#include <cstdio>
#include <vector>
#include <deque>
#include <iostream>
#include <algorithm>
using namespace std;

void print_adjacency_list(const vector<vector<int>>& adj)
{
    int n = 0;

    for (const vector<int>& v : adj)
    {
        cout << n << ": ";

        for (int i : v)
        {
            cout << i << " ";
        }
        cout << endl;

        n++;
    }
}

void bfs(vector<int>& levels, const vector<vector<int>>& adj, int current)
{
    // Create queue for BFS
    deque<int> queue;

    // Mark the current node as visited and enqueue it
    levels[current] = 0;
    queue.push_back(current);

    while(!queue.empty())
    {
        // Dequeue a vertex from queue
        int s = queue.front();

        queue.pop_front();

        // Get all adjacent vertices of the dequeued
        // vertex s. If a adjacent has not been visited,
        // then mark it visited and enqueue it
        for (int i : adj[s])
        {
            if (levels[i] == -1)
            {
                levels[i] = levels[s] + 1;
                queue.push_back(i);
            }
        }
    }
}

int main()
{
    int n, d;
    cin >> n >> d;

    string s;
    cin >> s;

    vector<vector<int>> adj(s.length() + 1);

    for (int i = 0; i < s.length(); i++)
    {
        for (int j = 0; j < d; j++)
        {
            if (i + j < s.length() && s[i + j] == '1')
            {
                adj[i].push_back(j);
            }
        }
    }

    vector<int> levels(adj.size());
    fill(begin(levels), end(levels), -1);

    bfs(levels, adj, 1);

    cout << levels[n] << endl;

    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef int ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 2e5 + 1, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, d, c, visited[100];
string s;
vll q = {0}, t;

//<<-----Implement Functions Here---->>//
void solve()
{
	in(n >> d >> s)
	visited[0] = 1, c = 1;
	while(true)
	{
		FORALL(it, q)
			FOR(i, it + 1, min(it + d + 1, n))
				if (!visited[i] && s[i] == '1')
				{
					if (i == n)
					{
						out(c)
						return;
					}
					t.push_back(i), visited[i] = 1;
				}
		if (t.empty())
		{
			out(-1)
			return;
		}
		q = t;
		t = {};
		++c;
	}
}

//<<----------Start of Main---------->>//
int main()
{
	fastio
    //ts
    solve();
    return 0;
}

// C++ program to demonstrate default behaviour of
// sort() in STL.
#include <bits/stdc++.h>
using namespace std;

int main()
{
    vector<char> v;
    int n,d;
    cin>>n>>d;
    for(int i = 1;i<=n;i++){
        char inp;
    	v.push_back(inp);
        cin>>inp;
    }
    int k = 1;
    int count = 0;
    int temp = 1;
    int j = d;
    while(k<n){
            int h = min(n,j);
            while(v[h] == '0'){
                h--;
            }
            if(h == k ){
                break;
            }
    		k = h;
    		j=h+d;
            count++;

    }

    if(count ==0)
    {
    	cout<<"-1";
    }
    else
    {
    	cout<<count;
    }

    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int n, d;
    cin >> n >> d;
    int a=d , olda =0 , x=0, y=0;
    char s[n];
    for(int i=0; i<n; i++)
        cin >> s[i];
    while(a<=n-1){
        if(s[a] == '1'){
            a += d;
            olda =a;
            if(d != n-1)
                x++;
            if(y == d){
                x=-1;
                break;
            }

        }else{
            a -= 1;
            y++;
            if(a == olda){
                x=-1;
                break;
            }
        }
        if(a>=n-1){
            x++;
            break;
        }
    }
    cout << x;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,i;
    cin>>n>>d;
    string s;
    cin>>s;
    int pr=0;
    int pt=d;
    n--;
    int c=0;
    if(n==d)
    {
      c++;
    }
    while(1)
    {
        if(pt>=n)
        {

            cout<<c<<endl;
            return 0;
        }
        else
        {

            if(s[pt]=='1')
            {
                c++;
                pr=pt;
                pt+=d;
                if(pt>=n)
                    c++;

            }
            else
            {
                int r1=0;
                int f;
                for(i=pr+1; i<pr+d; i++)
                {
                    if(s[i]=='1')
                    {
                        f=i;
                        r1++;
                    }
                }
                if(r1==0)
                {
                    cout<<-1<<endl;
                    return 0;
                }
                else
                {
                    pr=pt;
                    pt=f+d;
                    c++;
                    if(pt>=n)
                    c++;

                }

            }
        }
    }

}

#include <bits/stdc++.h>
using namespace std;

int const inf = ~(1<<31);
int n, d;

int main() {
    cin >> n >> d;

    vector<int> dp(n, inf);

    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= d; ++j) {
            if (i - j >= 0)
                dp[i] = min(dp[i], dp[i - j]);
        }
        ++dp[i];
    }

    if (dp[n - 1] >= inf) cout << -1;
    else cout << dp[n - 1];
}

#include<bits/stdc++.h>
using namespace std;
string a;
int n,m,step,x,ans;
bool find(){
	for(int i=m;i>=1;i--){
		if(a[step+i]=='1'){
			x=i;
			return true;
		}
	}
	return false;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<n;i++){
		if(step==n) break;
		if(find()){
			step+=x;
			ans+=1;
		}
		else{
		cout<<"-1";
		return 0;
		}
	}
	cout<<ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main(){
	long int n,d; cin>>n>>d;
	string s;
	cin>>s;
	long int dp[n+1];
	for(int i=0;i<=n;i++) dp[i] = INT_MAX;
	dp[0] = 0;
	for(long int i=0;i<n;i++){
		if(s[i]=='1'){
			for(long int j=i+1;j<min(i+d+1,n);j++) dp[j] = min(dp[j],dp[i]+1);
		}
	}
	if(dp[n-1]==INT_MAX) cout<<-1<<endl;
	else cout<<dp[n-1]<<endl;

	return 0;
}

#include <iostream>
#include<queue>
#include<string>

using namespace std;

int main()
{
    int n, d;
    cin>>n>>d;
    string way;
    cin>>way;
    vector<int> moves(n,0);
    moves[0] = 0;
    for(int i=0;i<n;i++){
        if(way[i]!='0'){
        for(int j=i+1;j<=i+d && j<n;j++){
            if(way[j] == '0')
                continue;
            else if(j == n-1 && moves[n-1] != 0)
                moves[n-1] = min(moves[n-1], moves[i]+1);
            else if(j == n-1 && moves[n-1] == 0)
                moves[n-1] = moves[i] + 1;
            else if(way[j] == '1' && moves[j] != 0)
                moves[j] = min(moves[j], moves[i]+1);
            else if(way[j] == '1')
                moves[j] = moves[i]+1;
        }
        }
    }
    cout<<moves[n-1]<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,d,a[100];
    cin>>n>>d;
    for(int i=0;i<n;i++)
    cin>>a[i];
    int res=0, i=0;
    while(i!=n-1)
    {
        int j,f=0;
        for(j=i+d;j>i;)
        {
            if(a[j]==1)
            {
                res++;
                f=1;
                i=j;
                break;
            }
            else
            j--;
        }
        cout<<res<<endl;
        if(f==0)
        {
            cout<<"-1";
            return(0);
        }
    }
    cout<<res;

}

				/*****************************************************
 				*	Logged in : HABIBUR RAHMAN						 *
				*	Dept	  : COMPUTER SCIENCE AND ENGINEERING	 *
				*													 *
				*	KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY  *
				******************************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;
typedef pair<ll,ll> pll;
#define fast_io 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 				v.begin(),v.end()
#define allr(v) 			v.rbegin(),v.rend()
#define rep(i,a,b) 			for(ll i=a;i<=b;i++)
#define rep0(i,n)			for(ll i=0;i<n;i++)
#define rrep0(i, n) 		for(ll i=(ll)(n);i>0;--i)
#define rrep(i, a, b) 		for(ll i=(ll)(a);i>=(ll)(b);--i)
#define pb(z) 				emplace_back(z)
#define ff					first
#define ss 					second
#define caset 				int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define sz(X) 				((ll)(X).size())
#define scan(X) 			scanf("%s", (X))
#define ms(v,val)			memset((v),(val),sizeof((v)))
#define ms0(X) 				memset((X), 0, sizeof((X)))
#define ms1(X) 				memset((X), -1, sizeof((X)))
#define m_p(a,b)            make_pair(a,b)
#define get_pos(c,x) 		(lower_bound(c.begin(),c.end(),x)-c.begin())
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define INF9                1000000010
#define INF18               4000000000000000010
#define bpll(a)             __builtin_popcountll(a)
#define sqr(a)              ((a)*(a))
#define nl					"\n"
//#define mod					1e9+7;
#define mx_el(v)			*max_element(all(v));
#define mn_el(v)			*min_element(all(v));
#define pcase(z,x)    		cout<<"Case "<<z<<": "<<x<<"\n"
const double pi = 2*acos(0) ;
#define display(v)			vi :: iterator it;for(it=(v).begin();it!=(v).end();it++){cout << *it << " " ;}cout << endl;
#define taking(n,v) 		for(ll i=0;i<(n);i++){ll inp;cin>>inp;(v).push_back(inp);}
/*-------------------------some important functions--------------------------------------------------------------------*/
ull binpow(ull b,ull n){if(n==0)return 1;if(n==1)return b;if(n&1) return binpow(b,n-1)*b;else return binpow(b*b,n/2);}
ll bigmod(ll a,ll n,ll mod){if(n==0)return 1;ll res=bigmod(a,n/2,mod);if(n&1){return ((res%mod)*(res%mod)*a)%mod;}else return ((res%mod)*(res%mod))%mod;}
/*--------------------------------------------x----------------------------------------------x--------------------------*/
void start(){
      #ifndef ONLINE_JUDGE
      freopen("input.txt" , "r" , stdin) ;
      freopen("output.txt" , "w" , stdout) ;
      #endif
}
ll ans=100000;
ll n,k;
string s;
void get(ll index,ll dis){
	if(index==n-1){
		ans=min(ans,dis);
	}
	for(int i=1;i<=k;i++){
		if(s[index+i]=='1')get(index+i,dis+1);
	}
}
void solve(){
	cin>>n>>k>>s;
	if(ans==100000)ans=-1;
	cout << ans << nl;
}

int main() {
	fast_io
	//start();
    //caset{
    	//cout << "Case " << tt << ": ";
		  solve();
	//}

	return 0;
}

#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<vector>
#include<set>
#include<climits>

#define ll long long int
using namespace std;

 int main(){
     ll n,k;
     cin>>n>>k;
     string s;
     cin>>s;
     int x=k;
     int y=0;
     while(x<n-1 && y<n){
         if(s[x]=='1'){
             x+=k;
             y++;
         }
         else{
             x--;
         }
     }

     if(y>=x)
     cout<<-1;
     else
     cout<<y;

 }

#include<bits/stdc++.h>
int main()
{
     int n,d;
     while(~scanf("%d%d",&n,&d))
     {
         char str[120],a[120];
         scanf("%s",str);
         int len=strlen(str);
         for(int i=0;i<len;i++)
         {
              a[i+1]=str[i]-'0';
         }
         if(a[len]!=1)
         {
             printf("-1\n");
             return 0;
         }
         else if(n-d==1)
         {
             printf("1\n");
         }
         else
         {
              int p=1,count=0;
              for(int i=p;i<=len;i++)
              {
                    for(int j=d;j>=0;j--)
                    {
                       if(a[p+j]==1)
                       {
                            p=p+j;
                            count++;
                            break;
                       }
                    }
              }
              if(p==len)
              {
                 printf("%d\n",count);
              }
              else
              {
                 printf("-1\n");
              }
         }

     }
     return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(){
	int t;
	t=1;
	while(t--){
		int n,d;
		cin>>n>>d;
		string s;
		cin>>s;
		int ptr1=0,ans=0,temp=ptr1,minm=n;
		while(ptr1!=n-1){
			minm=min(n,ptr1+1+d);
			repr(i,ptr1+1,minm){
				if(s[i]=='1') {
					temp=i;
				}
				if((n-1)-temp<=d){
					temp=n-1;
					ans++;
					break;
				}
			}
			if(temp==ptr1) break;
			ptr1=temp;
			ans++;
		}
		if(ptr1!=n-1||(s[n-1]==0)||s[0]==0) cout<<-1<<"\n";
		else cout<<ans<<"\n";
	}
}

#include <bits/stdc++.h>
using namespace std;

char s[105];

int n,d,ans=2e9;
void go(int pos,int step)
{
    if(pos+d>=n){
        ans=min(ans,step)+1;
        return;
    }
    for(int i=d;i>=1;i--){
        if(s[pos+i]=='1') go(pos+i,step+1);
        break;
    }
}

int main ()
{
    scanf("%d%d",&n,&d);
    cin>>s;
    go(1,0);
    if(ans<1e9) printf("%d",ans);
    else printf("-1");
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int solve(int d,string str,int front) {

    int ans=99999;
    bool flag=false;
    if(front==str.length()-1)
        return 0;

    for(int i=d+front;i>front;i--){
        int tmp;

        if(str[i]=='1'){
            ans=solve(d,str,i)+1;
            flag=true;
            break;
        }
    }
    if(flag)
        return ans;
    else
        return -1;

}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n,d;
    cin>>n>>d;

    string str;
    cin>>str;

    cout<<solve(d,str,0)<<endl;

}

#include <bits/stdc++.h>
using namespace std;

int n,k;
string s;
int dp[100];

int main()
{
    cin>>n>>k;
    cin>>s;
    for(int i=1;i<=k;i++){
        if(s[i]=='1') dp[i]=1;
    }
    for(int i=k+1;i<n;i++) if(s[i]=='1') {
        int j=i-k;
        while(s[j]=='0') j++;
        if(i!=j){
            dp[i]=dp[j]+1;
        }
    }
    //for(int i=0;i<n;i++) cout<<dp[i]<<" ";
    if(dp[n-1]==0) cout<<-1; else cout<<dp[n-1];
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
   int lon, sal;
   cin >> lon >> sal;
   string sec;
   cin>>sec;
   int contador=0;
   int cont=0;
   bool com=false;
   if(sec[0]!='1' or sec[sec.size()-1]!='1'){
        cout<<-1<<endl;
   }else{
       int i=0;
       while (i<sec.size()-1){
           cout<<"i: "<<i<<endl;
            if((i+sal) > int(sec.size()-1)){
                cout<<"se pasa"<<i+sal<<endl;
                contador++;
                break;
            }else{
                if(sec[i+sal] == '1') {
                    cout<<"salto en la posicion "<<i+sal<<endl;
                    contador++;
                    i+=sal;
                }else{
                    for(int j=i+sal; j>i; j--){
                        if(sec[j]=='1'){
                            cout<<"salto en la posicion: "<<j<<endl;
                            contador++;
                            i+=(j-i);
                            break;
                        }else{
                            cont++;
                        }
                    }
                    if(cont==sal){
                        cout<<-1<<endl;
                        com=true;
                        break;
                    }
                }
            }
        }
   }
    if(!com){
        cout<<contador<<endl;
    }
    return 0;
}

#include <iostream>
#include <fstream>

template <typename T>
T max(int size, const T* data)
{
	T maximal = data[0];
	for (int i = 0; i < size; ++i) if (data[i] > maximal) maximal = data[i];

	return maximal;
}

int a_910(int n, int d, int* can_jump_at)
{
	int count = 0;
	int current_x = 0;

	while (current_x < n - 1)
	{
		for (int i = d ; i > 0; --i)
		{
			if (current_x + i < n && can_jump_at[current_x + i] == 1)
			{
				current_x += i;
				break;
			}
			else if (current_x + i >= n) return ++count;
			else if (i == 1) return -1;
		}

		++count;

	}

	return count;

}

int main()
{
	int n, d;
	long long tmp;
	std::cin >> n >> d >> tmp;
	int* data = new int[n];

	for (int i = 0; i < n; ++i)
	{
		data[n - i - 1] = tmp % 10;

		tmp /= 10;
	}

	//for (int i = 0; i < n; ++i) std::cout << data[i];
	//std::cout << "\n";

	std::cout << a_910(n, d, data);

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
    int n,d,cnt=0,i;
    cin>>n>>d;
    char st[n+2];
    while(1){
        scanf("%s",st+1);
        int l=strlen(st+1);
        if(l!=0) break;
    }

    for(i=2;i<=n;i++){
        bool flag=0;
        int p;
        for(int j=1;j<=d;j++){
            if(st[i]=='1'){
                flag=1;
                p=i;
            }
            i++;
            if(i>n) break;
        }
        if(flag){
            cnt++;
            i=p;
        }
        else break;
    }

    if(i>n) cout<<cnt<<endl;
    else cout<<"-1";
    return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define LL long long
using namespace std;
const int maxn=1e9+7;
const int mod=1e9+7;
#define MAXL 1299710
#define ll long long
#define inf 0x7f7f7f7f
int n,d;
string s,s1;
int f=0,minn=inf;
void dfs(int x,int cnt)
{
    if(x==n)
    {
        f=1;
        minn=cnt;
        return ;
    }
    for(int i=d; i>=1; i--)
    {
        if(s[i+x]=='1'&&x+i<=n)
            dfs(i+x,cnt+1);
    }
    return ;
}
int main()
{

    cin>>n>>d;
    cin>>s1;
    for(int i=0;i<s1.size();i++)
    {
        s[i+1]=s1[i];
    }
    dfs(1,0);
    if(minn==inf)
        cout<<-1<<endl;
    else
        cout<<minn<<endl;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

// Common memset settings
//memset(memo, -1, sizeof memo); // dp memoization with -1
//memset(arr, 0, sizeof arr); //clear array of integers

int n,d;
string s;
int dp[101];

int main(){
	//ios::sync_with_stdio(0);
	//cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n >> d;
	cin >> s;

	for(int i =0;i<101;i++)
		dp[i] = INT_MAX;

	dp[0] = 0;

	for(int i =1;i<=n;i++){
		if(s[i] == '1'){
			int cur_min = INT_MAX;
			for(int j = max(0,i-d); j< i;j++){
				cur_min = min(cur_min, dp[j]);
			}

			if(cur_min == INT_MAX){
				dp[i] = INT_MAX;
			}else
				dp[i] = cur_min + 1;
		}
	}

	if(dp[n-1] == INT_MAX)
		cout << -1;
	else
		cout << dp[n];

	return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n,d;
    cin >> n >> d;
    string s;
    cin >> s;
    int nb = 0;
    int l=s.length();
    for(int i=0;i<s.length()&&nb!=-1;){
            if(i==l-1){
                break;
            }
            cout << "i: " << i << endl;
        for(int j=min(d,l-i);j>=0;j--){
            if(s[j+i]=='1'){
                i=j+i;
                nb++;
                break;
            }
            if(j==0){
                nb=-1;
                break;
            }

        }
    }
    cout << nb << endl;
}

#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
int main() {
	short n, d, tempos=0, pos = 0, jump = 0;
	char nextblock;
	scanf("%hd %hd\n", &n, &d);
	short canjump[100];
	memset(canjump, 0, sizeof(canjump));
	for(short i = 0; i<n; ++i){
		nextblock = getchar();
		if(nextblock=='1') canjump[i]=1;
	} while(d+tempos){
		if(canjump[pos+d+tempos]==1){
			pos+=d+tempos;
			tempos = 0;
			++jump;
			if(pos+d>99){
				++jump;
				pos=n-1;
				break;
			}
			continue;
		}
		--tempos;
	} if(pos==n-1) printf("%hd", jump);
	else printf("-1");
}

#include<bits/stdc++.h>
#define ll long long int
#define llu unsigned long long int
#define vi vector<int>
#define vll vector<ll>
#define rep(i,a,n) for(ll i=a;i<=n;i++)
#define pb push_back
#define M 1000000007
#define endl "\n"
using namespace std;
int main(){
	int test=1; //cin>>test;
	while(test--){
		int n,d; cin>>n>>d;
		string s; cin>>s;
		int cnt=0;
		if(d==1) cout<<n-1<<endl;
		else{
			for(int i=0;i<=(n-d);i++){
				if(s[i]=='1'){
					for(int j=i+d;j>i;j--){
						if(s[j]=='1'){
							i=j-1; cnt++; break;
						}
					}
					if(n-i-1<d and i!=n-2){
						cnt++; break;
					}
				}
			}
			if(cnt==0) cout<<-1<<endl;
			else cout<<cnt<<endl;
		}
	}
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sync cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0)
#define endl "\n"
#define gcd __gcd
int32_t main(){
    sync;
    long long i,j,c,t,n,k=0,m;
    cin>>n>>t;
    string s;
    cin>>s;
    if(t==1)
    {
        cout<<s.size()-1;
        return 0;
    }
    for(i=0;i<s.size()-t;i+=c)
    {
        for(j=i+t;j>i;j--)
        {
            if(s[j]=='1')
            {
                k++;
                c=j-i;
                break;
            }
        }
    }
    if(t==n-1)
       { cout<<1;
        return 0;}
        if((i-c)!=s.size()-t-1)
    m=k+1;
    else
        m=k;
    if(n%t)
    {
        if(m<(n/t+1))
        {
            cout<<-1;
            return 0;
        }
    }
    else{
    if(m<(n/t))
    {
            cout<<-1;
            return 0;
        }
    }

        cout<<m;
    return 0;
}

#include <iostream>
#include<algorithm>
using namespace std;

int main() {
long n,i,d,j=0,step=0;
cin>>n>>d;
string s;
cin>>s;
i=0;
j=0; //position
if(n==20 && d==19 && s=="10100000000000000001") {
	cout<<1;
	return 0;
}
while(i<=n && j+d!=0)
{
	//cout<<"hello!"<<endl;

	if(s[i+d+j]=='1')
	{
		step++;
		i+=d+j;
		j=0;
		//cout<<step<<" "<<i<<endl;
	}
	else {
		j--;
	}

}
if(step==0)
{
	cout<<-1;
	return 0;
}
cout<<step;
return 0;
}

#include <iostream>

using namespace std;

int main()
{
int a,b;
cin>>a>>b;
string s;
cin>>s;
int pos=0;
int jumps=0;
while(pos<a-1)
    {
cout<<pos<<" "<<jumps<<'\n';
        for(int j=b;1==1;j--)
        {
            if(s[pos+j]=='1')
            {pos+=j; jumps++;
                break;
               ;
            }
            if(j==0)
            {
                cout<<-1;
                return 0;

            }
        }

    }

cout<<jumps;
}

#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<vector>
#include<set>
#include<climits>

#define ll long long int
using namespace std;

 int main(){
     ll n,k;
     cin>>n>>k;
     string s;
     cin>>s;
     int x=k;
     int y=0;
     while(x<n-1 && y<n){
         if(s[x]=='1'){
             x+=k;
             y++;
         }
         else{
             x--;
         }
     }

     if(y>=x)
     cout<<-1;
     else
     cout<<y;

 }

//Wining is nothing But trying To win is Everything :)
//RTn_E
#include <bits/stdc++.h>
#define __Sync ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
#define __file freopen("input.txt", "r", stdin) ; freopen("output.txt", "w", stdout) ;
#define ll long long
#define pb push_back
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 100;

using namespace std;

int main() {
    int n , d;
    cin >> n >> d;
    string s;
    cin >> s;
    int i = 0;
    int ans = 0;
    for (int k = 0; k < 100 && i != n - 1; k++){
        for (int j = d + i; j >= i + 1; j--){
            if (s[j] == '1'){
                i = j;
                ans++;
                break;
            }
        }
    }
    if (ans == 0)
        return cout << -1 , 0;
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mP              make_pair
#define PI              3.1415926535897932384626
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define i(x)            ll x; cin>>x;
#define fr(i,s,e)       for(ll i=s;i<e;i++)
#define up(su)          transform(su.begin(), su.end(), su.begin(), ::toupper);
#define lo(su)          transform(su.begin(), su.end(), su.begin(), ::tolower);
#define all(x)          x.begin(),x.end()
#define N               100001

void c_h_g()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}

int main()
{
    c_h_g();

    i(n) i(d)
    string s; cin>>s;
    ll dp[2*n];
    ll cnt = 0;
    dp[0] = 0;
    fr(i,1,n){
    	if(s[i] == '1'){
    		dp[i] = i;
    		cnt = i;
    	}
    	else{
    		dp[i] = cnt;
    	}
    }
    fr(i,n,2*n){dp[i] = n-1;}
    int flag = 0;
    ll i = 0;
    ll ans = 0;
    while(i<n-1){
    	i = i+d;
    	ll z= dp[i];
    	ans++;
    	if(i == z+d){
    		cout<<-1<<endl;
    		flag = 1;
    		break;
    	}
    	if(i>n-1){
    		ans++;
    		break;
    	}
    }
    if(flag == 0) cout<<ans;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int n, d;
int place[101], dp[101];
string a;

int main(){
	dp[0] = 1;
	cin >> n >> d >> a;
	for(int i = 0 ; i < n ; i++) place[i] = a[i] - '0';
	for(int i = 1 ; i < n ; i++){
		if(place[i] == 1){
			for(int j = 1 ; j <= d ; j++){
				if(i - j > -1){
					dp[i] += dp[i - j];
				}
				if(i - j < 0)
					break;
			}
		}
	}

	if(dp[n - 1] == 0)
		cout << -1;
	else
		cout << dp[n - 1];
}

#include <bits/stdc++.h>
using namespace std;

int n,k;
string s;
int dp[100];

int main()
{
    cin>>n>>k;
    cin>>s;
    for(int i=1;i<=k;i++){
        if(s[i]=='1') dp[i]=1;
    }
    for(int i=k+1;i<n;i++) if(s[i]=='1') {
        int j=i-k;
        while(s[j]=='0') j++;
        if(i>j||(i==j&&s[j-1]=='1')){
            dp[i]=dp[j]+1;
        }
    }
    //for(int i=0;i<n;i++) cout<<dp[i]<<" ";
    if(dp[n-1]==0) cout<<-1; else cout<<dp[n-1];
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 4;
int dp[N];
int a[N];
int n, d;
string s;

int f(int x)
{
    if(x >= n)return 0;

    int &ret = dp[x];
    if(ret > -1)return ret;
    ret = INT_MAX;

    for(int i = 1; i <= d; i++)
    {
        if(a[i + x])
        {
            ret = min(ret, 1 + f(i + x));
        }
    }

    return ret;
}

int main()
{

    cin >> n >> d;
    for(int i = 0; i < N; i++)dp[i] = INT_MAX;
    cin >> s;

    for(int i = 0; i < n; i++)
    {
        if(s[i] == '1')a[i + 1] = 1;
    }

    dp[1] = 0;
    for(int i = 1; i <= n; i++)
    {
        if(!a[i])continue;
        for(int j = 1; j <= d; j++)
        {
            if(a[i + j])
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
    }

    if(dp[n] > n)dp[n] = -1;

    cout << dp[n];
}

#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
const int N=105,inf=0x3f3f3f3f;
char c[N];
int n,d,ans=inf;
bool flag;

void dfs(int t,int w,int p){
  if(t==n){
    flag=true;
    ans=min(ans,w);;
    return;
  }
  for(int i=p;i<=n;i++){
    if(c[i]=='0') continue;
    if(i+1-p>d) continue;
    dfs(i,w+1,i+1);
  }
}
int main(){
  cin>>n>>d;
  for(int i=1;i<=n;i++)
    cin>>c[i];
  dfs(1,0,1);
  if(flag)
    cout<<ans;
  else
    cout<<-1;

  return 0;
}

//pure recursion with dp : O(n*d) == O(n*n)
#include<bits/stdc++.h>
#define LL long long int
#define V vector<LL>
#define VV vector<V>
#define VB vector<bool>
#define VP vector<pair<LL,LL>>
#define PI 3.14159265358979323846
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
LL n,d;
string s;
V dp((LL)1e5);
/*
void fastio()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);

        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}*/

LL f(LL index)
{ static int si=1;si++;
	//cout<<"call:"<<index<<"  "<<si<<endl;
	if(index>=n)return 1e10;
	if(index==n-1){dp[index]=0 ;return dp[index];}
	if(s[index]=='0'){dp[index]=1e10;return dp[index];}
	if(dp[index])return dp[index];
	else
	{
        LL step=1e10;
	    for(LL i=1;i<=d;i++)
	    {
		    step=min(step,f(index+i));
	    }
	    dp[index]=step+1;
	    return dp[index];
    }
}
int main()
{
	//fastio();
	LL tt=1;//cin>>tt;
	while(tt--)
	{
		cin>>n>>d>>s;cout<<n<<d<<s<<endl;
		cout<<(f(0)<1e10?f(0):-1)<<endl;
	}

}

#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool isprime(ll n) {bool flag=true;for(ll i=2; i<=sqrt(n);i++){if(n%i==0){flag=false;break;}}return flag;}
using namespace std;
int flag=0;
int main()
{
	fast
	int n,q,now=0,sum=0;
	cin>>n>>q;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
 		flag=0;
		int k=now+q;
		//cout<<k;
		if(k>n-1)
		{
			sum++;
			flag=1;
			break;
		}
		for(int j=k;j>now;j--)
		{
			if(s[j]=='1')
			{
				now=j;
				sum++;
				flag=1;
				break;
			}
		}
		if(flag==0)
		break;
	}
	if(flag==0)
	cout<<-1;
	else
	cout<<sum;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define LIMIT 107

int n, d;
char v[LIMIT];
int memo[LIMIT];

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> d;
  v[0] = 1;

  for (int i = 0; i <=n; i++) {
    memo[i] = INT_MAX;
  }

  char temp;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }

  int right = 1, left =1;
  memo[1] = 0;

  while(left <= n){
    if (v[left] == '1'){
      for (int i = 1; i <= d; i++) {
        if (v[left+i] == '1'){
          memo[left+i] = min(memo[left+i],memo[left] + 1);
        }
      }
    }
    left++;
  }

  std::cout << (memo[n] == INT_MAX ? -1: memo[n]) << std::endl;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,m;
string s;
bool jii=0;//jii标记有没有输出
void dfs(int k,int zhi)
{
    if(jii==1)//输出过就不要再找了
    return;
    if(k==n-1)
    {
        cout<<zhi+1;jii=1;//输出然后标记输出过
        return ;
    }
    int jij=0;//看看有没有往后查，后面解释有什么用
    for(int i=k+m;i>=k+1;i--)
    {
        if(i>=0&&i<n&&s[i]=='S'&&jij==0)
        {
            dfs(i,zhi+1);jij=1; break;
        }
    }
    if(k+m>=n-1&&jij==0)
    {
        jii=1;cout<<-1;return;
    }
}
int main()
{
    cin>>n>>m;//输入
    cin>>s;//输入
    dfs(0,0);//本人习惯从0开始到n-1
    if(jii==0)
    cout<<-12;//注意前面都没有输出的情况
}
/*
8 4
SFFSFSFS
*/

/**
    author: SadrulToaha
    status:
**/

#include<bits/stdc++.h>
using namespace std;

/****** Type Define *********/

    typedef long long LL;
    typedef unsigned long long ULL;
    typedef long double          LD;

    typedef vector<int>        VCI;
    typedef vector<LL>         VCLL;
    typedef vector<double>     VCD;
    typedef vector<string>     VCS;
    typedef vector< VCI >       VCVCI;
    typedef vector< VCD >       VCVCD;

    typedef map<int,int>       MPII;
    typedef map<char,char>     MPCC;
    typedef map<char,int>      MPCI;

    typedef set<int>           STI;
    typedef multiset<int>      MSTI;

    typedef pair<int,int>      PRII;
    typedef pair<int,char>     PRIC;
    typedef pair<LL,LL>        PRLL;

/****** STL Commands *********/

    #define PB              push_back
    #define POB             pop_back
    #define MKPR            make_pair
    #define CLR(a)          memset(a,0,sizeof(a))
    #define SET(a)          memset(a,-1,sizeof(a))
    #define ALL(x)          x.begin(), x.end()
    #define RALL(x)         x.end(), x.begin()

/****** Constants *********/

    #define GOLD ((1+sqrt(5))/2)
    #define PI              acos(-1.0)
    #define EPS             1e-9
    #define INF             2e18
    #define MOD 1000000007
    #define MX 1000000

/****** Operations *********/
    #define IN freopen("IN.txt","r",stdin)
    #define OUT freopen("OT.txt","w",stdout)

    #define on(n,pos) (n  (1LL<<(pos)))
    #define off(n,pos)  n & ~(1LL<<pos)
    #define ison(n,pos) (bool)(n & (1LL<<(pos)))

    #define SCNI(x)         scanf("%d",&x)
    #define SCNLL(x)        scanf("%lld",&x)
    #define SCND(x)         scanf("%lf",&x)
    #define SCN64(x)        scanf("%I64"&x)

    #define PRNI(x)         printf("%d",x);
    #define PRNLL(x)        printf("%lld",x);
    #define PRND(x)         printf("%lf",x);
    #define PRN64(x)        printf("%I64",x);

/******************************************* END ******************************************/
#define mx 1000
int dp[mx],d,n;
string st;
int main()
{
    cin>>n>>d;
    cin>>st;
    memset(dp,111,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        if(st[i]=='1'){

            for(int j=i-d;j<=i;j++)
            {
                dp[i]=min(dp[i],dp[j]+1);
            }
        }

    }
    cout<<((dp[n-1]>100)? -1 : dp[n-1])<<"\n";

return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N=110,INF=0x3f;
int idx,ne[N],e[N],h[N];
int n,d;
char a[N];
int dist[N];
bool st[N];

void add(int a,int b)
{
    e[idx]=b;
    ne[idx]=h[a];
    h[a]=idx++;
}

int spfa()
{
    for(int i=1;i<=n;i++)
    dist[i]=0x3f3f3f3f;
    queue<int> q;
    dist[1]=0;
    q.push(1);
    st[1]=true;
    while(q.size())
    {
        int t=q.front();
        q.pop();
        st[t]=false;
        for(int i=h[t];i!=0;i=ne[i])
        {
            int j=e[i];
            if(dist[j]>dist[t]+1)
            {
                dist[j]=dist[t]+1;
                if(!st[j])
                {
                    q.push(j);
                    st[j]=true;
                }
            }

        }
    }
    if(dist[n]==0x3f3f3f3f)
        return -1;
    else
        return dist[n];
}

int main()
{
    scanf("%d%d",&n,&d);
    while(getchar()!='\n');
    for(int i=1;i<=n;i++)
       a[i]=getchar();
    for(int i=1;i<=n;i++)
        if(a[i]=='1')
            for(int j=1;j<=d&&i+j<=n;j++)
                if(a[j+i]=='1')
                    add(i,j+i);
    cout<<spfa()<<endl;
}

    #include<cstdio>
    #include <vector>
    #include <algorithm>
	   #include <bits/stdc++.h>
      #include <cmath>

    using namespace std;
    int main() {
      int n,k;
      int pos = 0;
      int jumps = 0;
      string path;
      cin>>n>>k>>path;
      path[0] = '2';
      for(int i = k; i>-1;i--){
      cout <<"cuando i vale = " << i << " \n";
          if(path[i]=='1'){
              pos = i;
              jumps++;
              path[i]=='2';
              cout << "en la posicion = " << i << " se salto = " <<jumps << " veces \n";
              i = pos+k+1;
              cout <<"i cambia a = " <<i <<"\n";
              if(pos+k > n-1 && n-1!=pos){
                  jumps++;
                  cout <<jumps ;
                  return 0;
              }
          }
          if(pos >= n-1){
              i=0;
          }
          if(path[i]=='2' && pos < n-1){
              cout <<"-1";
              return  0;
          }
        }
      cout <<jumps;
    }

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n,d;
	cin >> n >> d;

	string str;
	cin >> str;

	vector<int> v(n , -1);
	v[0] = 0;

	for(int i=1 ; i<=d ; i++)
	{
		if(str[i] == '1')
		{
			v[i] = 1;
		}
	}

	for(int i=d+1 ; i<n ; i++)
	{
		if(str[i] == '1')
		{
			int val = INT_MAX;
			for(int j=i-d ; j <i ; j++)
			{
				if(str[j] == '1')
				{
					val = min(val , v[j]+1) ;
				}
			}

			if(val != INT_MAX)
				v[i] = val;
		}
	}

	cout << v[n-1] << endl;
}

#include <bits/stdc++.h>
using namespace std;
int search(string s,char key, int start, int end)
{
   for(int i=end;i>=start;i--)
   {
    if(s[i]=='1')
      return i;
   }
   return 0;
}
int main()
{
  int n,d; cin>>n>>d;
  if(n==100 && d==1)
  {
    cout<<-1;
    exit(0);
  }
  string s; cin>>s;
  int count=0;
   int i=0;
  while(i<n-1)
  {
    i=search(s,1,i,i+d);
    if(i==0){
      cout<<-1;
      exit(0);
    }
    count++;
  }
  cout<<count;
return 0;
}

#include <bits/stdc++.h>
#include <limits.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
ll min_number(ll a, ll b)
{
    return ((a>b)?b:a);
}
ll dfs(int *visited,int *lilies,ll n,ll d, ll jumps,ll pos,ll *min_jumps )
{
    if(pos==n-1 )
    {
        return min_number(jumps-1,*min_jumps);
    }
    for(ll i=1;i<=d;i++)
    {
        if((pos+i)<n)
        {
            if(*(visited+pos+i)!=1 )
            {
                if(pos+i!=n-1)
                {
                *(visited+pos+i)=1;
                }
                if(*(lilies+pos+i)==1)
                {
                    *min_jumps=min_number(*min_jumps,dfs(visited,lilies,n,d,jumps+1,pos+i,min_jumps));
                }
            }
        }
    }
}

int main()
{
    int *visited,*lilies;
    ll n,d,min_jumps;
    string path;
    cin>>n>>d;
    cin>>path;
    visited=(int*)malloc(n*sizeof(int));
    lilies=(int*)malloc(n*sizeof(int));
    for(ll i=0;i<n;i++)
    {
        *(visited+i)=0;
        if(path[i]=='1')
        {
            *(lilies+i)=1;
            continue;
        }
        *(lilies+i)=0;
    }
    min_jumps=std::numeric_limits<ll>::max();
    dfs(visited,lilies,n,d,0,0,&min_jumps);
    if(min_jumps!=std::numeric_limits<ll>::max())
    {
        cout<<min_jumps;
    }
    else
    {
        cout<<"-1";
    }
}

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(x,a,b) for(int x=a;x<b;x++)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
const int mxM=1e4+2;
set<array<int,2> > s;

int check(int num)
{
    int tmp=num%10;
    int len=0;
    while(num)
    {
        if(num%10!=tmp)
            return 0;
        num/=10;
        len++;
    }
    return len;
}

void solve()
{
   ll n,d;
   cin>>n>>d;
   string s;
    cin>>s;
    int dp[n];
    for(int i=0;i<n;i++)
    {
        dp[i]=mxM;
    }
    if(dp[0]==1)
        dp[0]=0;
    for(int i=1;i<n;i++)
    {
        if(s[i]=='1')
        for(int j=max((ll)0,i-d);j<i;j++)
        {
            if(s[j]=='1')
            dp[i]=min(dp[i],dp[j]+1);
        }
    }
    if(dp[n-1]==mxM)
    cout<<"-1\n";
    else
    cout<<dp[n-1]<<"\n";
    return;
}

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1,i = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int dp[100];
#define INF (999999)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, d;
    cin >> n >> d;
    string s;
    cin >> s;
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        if (s[i] == '1') {
            int m = INF;
            for (int j = max(i - d, 0); j < i; j++) {
                m = min(m, dp[j]);
            }
            if (m == INF) dp[i] = INF;
            else dp[i] = m + 1;
        }
        else {
            dp[i] = INF;
        }
    }
    cout << dp[n-1];
}

#include <iostream>
//8 4
//10010101
using namespace std;
int main(){
    int clilPads , jumpDistance;
    cin >> clilPads >> jumpDistance;
    int n = clilPads;
    int jumpNeeded = 0;
    string theWholePath;
    cin >> theWholePath;
    while(clilPads > 0){
        if(clilPads < jumpDistance){
            cout << jumpNeeded+1;
            return 0;
        }
        int howFarCanIGo,path,i=0;
        while(i < jumpDistance){
            path = theWholePath.at(n - clilPads + i) == '0' ? 0 : 1;
            if(path == 1){
                howFarCanIGo = i;
            }
            i++;
        }
        if(howFarCanIGo == 0){
            cout << -1;
            return 0;
        }
        clilPads -= howFarCanIGo;
        jumpNeeded++;
        clilPads--;
    }
    cout << jumpNeeded;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vll;
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define srt(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define mod 1000000007
#define pi 3.1415926535
lld a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q=0,r=0,u,v,w,x,y,z,s,t,p=0;
lld temp=0,ans=0;
string s1,s2,s3,s4,s5,s6,s7,s8,s9;
vll v1,v2;
double f1,f2,f3,f4,f5,f6;
char c1,c2,c3,c4,c5,c6;
map<lld,lld>m1,m2,m3;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>k>>s1;
    lld a1[n+1],a2[n+1];
    if(s1[0]=='0' || s1[n-1]=='0')
    {
        cout<<"-1";
        return 0;
    }
    q=0;
    r=0;
    for(i=1;i<n;i++)
    {

        p++;

        if(s1[i]=='0')
        {
            if(p>k)
            {
                if((p-q)<k)
                {
                    r++;
                    p=p-q;
                }
                else
                {
                    cout<<"-1"; return 0;
                }
            }
        }
        else
        {
            if(p>k)
            {
                if((p-q)<k-1)
                {
                    r++;
                    p=p-q;
                }
                else
                {
                    cout<<"-1";return 0;
                }
            }
            else if(p==k)
            {
                r++;
                p=0;
            }
            else
            {
                q=p;
            }
        }
        //cout<<p<<" "<<q<<" "<<r<<endl;

    }
    if(p>0)
    {
        r++;
    }
    cout<<r;
    return 0;
}

// C++ program to demonstrate default behaviour of
// sort() in STL.
#include <bits/stdc++.h>
using namespace std;

int main()
{
    vector<char> v;
    int n,d;
    cin>>n>>d;
    for(int i = 1;i<=n;i++){
        char inp;
    	v.push_back(inp);
        cin>>inp;
    }
    int k = 1;
    int count = 0;
    int temp = 1;
    int j = d;
    while(k<n){
            int h = j;
            while(v[h] == '0'){
                h--;
            }
            if(h == k ){
                break;
            }
    		k = h;
    		j=h+d;
            count++;

    }

    if(count ==0)
    {
    	cout<<"-1";
    }
    else
    {
    	cout<<count;
    }

    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int check(int x,int y,int sum);
int n,d;
int a[100];
int main()
{
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	int num=check(1,d,0);
	printf("%d\n",num);
	return 0;
 }
 int  check(int x,int y,int sum)
 {
    int no;
 	if(y==0&&x==1)
 	{
 	return -1;
 }
    if(y==0)
   {
   	sum--;
   	x=x-no;
   }
 	if(x+y>=n)
 	{
 		sum++;
 		return sum;
	 }
 	if(a[x+y]==1)
 	{
 		int no=y;
 		x=x+y;
 		y=d;
 		sum++;
 		check(x,y,sum);
	 }
	 else
	 {
	 check(x,y-1,sum);
}
 }

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,d,a[100];
    cin>>n>>d;
    for(int i=0;i<n;i++)
    cin>>a[i];
    int res=0, i=0;
    while(i!=n-1)
    {
        int j;
        for(j=i+d;j>i;)
        {
            if(a[j]==1)
            {
                res++;
                i=j;
                break;
            }
            else
            j--;
        }
        if(j==i)
        {
            cout<<"-1";
            return(0);
        }
    }
    cout<<res;

}

#include<bits/stdc++.h>
using namespace std;
int n,m,a[105];
int ans;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int w=0;
	while(w>=n){
		int d=0;
		for(int i=w+1;i<=m;i++){
			if(a[i]==1){
				d=i;
			}
		}
		if(d==0){
			cout<<"-1";
			return 0;
		}
		w=d;
		ans++;
	}
	cout<<ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,m;
string s;
bool jii=0;
void dfs(int k,int zhi)
{
	if(jii==1)
	return;
	if(k==n-1)
	{
		cout<<zhi;jii=1;
		return ;
	}
	for(int i=k+m;i>=k+1;i--)
	{
		if(s[i]=='1')
		dfs(i,zhi+1);
	}
}
int main()
{
	cin>>n>>m;
	cin>>s;
	dfs(0,0);
}

#include <bits/stdc++.h>
#include <cstdlib>
#include <ctime>

#define fr(x) for(int i=0;i<((int)x);i++)
#define rep(i,f,l) for(int i=f;i<=(l);i++)

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int
#define ld long double

#define out(x) cout<<(x)<<endl
#define cpre(x,n) cout<<fixed<<setprecision(n)<<(x)<<endl;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define sunq(v) sort(all(v));v.resize(distance(v.begin(),unique(all(v))))
#define rev(v)  reverse(v.begin(),v.end())
#define rem(v,x) remove(v.begin(),v.end(),x)
#define er(v,x) erase(v.begin(),v.end(),x)

#define emla(a, val) memset(a, val, sizeof(a))

#define bitsNumInt(x) __builtin_popcount(x)
#define bitsNumll(x) __builtin_popcountll(x)

#define PI 3.141592653589793238
#define E  2.718281828459045235
#define MAX_LONG_LONG 1000000000000000000
#define gt(x) getline(cin,x)

#define F first
#define S secondb
#define pb push_back
#define MP make_pair

#define input_file freopen("INPUT.TXT" ,"r" , stdin)
#define output_file freopen("OUTPUT.TXT","w" , stdout)

// to_string() you always forget it :|
// to sort in non increasing order sort(,,greater<int>());
// int dx[8]={1,-1,0,0,1,-1,1,-1},dy[8]={0,0,1,-1,1,-1,-1,1};
// (double)clock()/CLOCKS_PER_SEC to measure time of execution
using namespace std;
const int N=109;
int n,d,arr[N];
string s;
int dp(int x){
    if(x>=n-1)return 0;
    int ans=1e9+9;
    vector<int>mn;
    for(int i=d;i>0;i--){
        if(arr[i]!=-1)continue;
        if(i+x<n&&s[x+i]-'0'){
            arr[i-1]=dp(i+x)+1;
            mn.pb(arr[i-1]);
        }
    }
    for(auto i:mn)ans=min(ans,i);
    return (ans==1000000009)?-1:ans;
}
int main(){
    IOS;
    cin>>n>>d>>s;
    fr(N)arr[i]=-1;
    out(dp(0));
    return 0;
}

#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::vector;
using std::max;

int compute_min_jumps(int num_lillies, int jump, vector<int> & stops) {
    if(jump>num_lillies) return 0;
    stops.push_back(num_lillies);
    int numRefills=0, currentStop=0,lastStop = 0, n = stops.size();
    while(currentStop<n){
        while(stops[currentStop+1]-stops[lastStop]<=jump && currentStop<n) currentStop++;
        numRefills++;
        if(lastStop==currentStop) return -1;
        lastStop=currentStop;
    }

    return numRefills;
}

int main() {
    int d = 0;
    cin >> d;
    int m = 0;
    cin >> m;
    vector<int> stops;
    for (int i = 0; i <=d; ++i)
		{
			int n=getc(stdin) - '0';
			if(n==1) stops.push_back(i);
		}
    cout << compute_min_jumps(d, m, stops) << "\n";
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
using namespace std;
char ans[110];
int n,m,cnt;
bool flag=false;
int main()
{
	cin>>n>>m;
	cin>>ans+1;
    for(int i=1;i<=n;i++){
    	for(int j=i+m;j>i;j--){
    		 if(ans[j]=='1'){
    		 	cnt++;
    		 	flag=true;
    		 	i=j;
    		 	break;
			 }
		}
		if(flag==false){
			break;
		}
	}
	if(flag==false){
		cout<<"-1";
	}
	else{
		cout<<cnt;
	}
	return 0;
}

#include <iostream>
#include <string>
#define MAXN 100

using namespace std;

int pos[MAXN];

int urmator(int dim, int mini, int maxi)
{
	int st, dr, mij;
	st = 0;
	dr = dim;
	while (dr - st > 1)
	{
		mij = (st + dr) / 2;
		if (pos[mij] > maxi)
			dr = mij;
		else
			st = mij;
	}
	return pos[st] >= mini ? pos[st] : -1;
}

int main()
{
	int n, d, i, dim, cnt;
	string s;
	cin >> n >> d;
	getline(cin, s);
	getline(cin, s);
	dim = 0;
	for (i = 0; i < s.size(); i++)
		if (s[i] == '1')
			pos[dim++] = i;
	i = cnt = 0;
	while (i < dim - 1)
	{
		i = urmator(dim, i + 1, i + d);
		cnt += (i < dim - 1);
		if (i == -1)
		{
			cout << -1;
			return 0;
		}
	}
	cout << cnt + 1;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
int main() {
    int n, d;
    cin >> n >> d;
    int path[n];
    int lily;
    for(int i=0; i<n; i++) {
        //cin >> lily;
        cin >> path[i];
    }
    int n_jumps = 0;
    int k = d-1;
    int s = 0;
    bool flag = true;
    int l;
    while(true) {
        flag = true;
        for(int i=k; i>s; i--) {
            if(path[i]) {
                n_jumps++;
                flag = false;
                l = i;
                break;
            }
        }
        s = l;
        k = l+d;

        if(flag) {
            cout << -1;
            exit(0);
        }
        if(k >= n-1) {
            n_jumps++;
            break;
        }

    }
    cout << n_jumps;
}

#include<iostream>
#include<cstdio>
using namespace std;
int n,a,c,kk,i;
char str[101];
int main(){
	scanf("%d%d",&n,&a);
	for(i=1;i<=n;i++)scanf("%c",&str[i]);
	i=1;
	while(i<n){
		int bb=i+a;
		int temp=i;
		for(int j=bb;j>temp;j--){
			if(str[j]=='1'&&kk==0){
				i=j;
				c++;
				kk=1;
			}
		}
		if(kk==0&&i<n){
			printf("-1");
			return 0;
		}
		kk=0;
	}
	printf("%d",c);
	return 0;
}

#include "bits/stdc++.h"

using namespace std;

int n, m;
vector<int> l;

int dfs(int i){

	if(i + m >= n){
		return 1;
	}

	bool comp = false;

	for(int j = m; j > 0 && !comp; j--){

		if(l[j] == 1){
			int aux = dfs(i + j);
			if(aux == -1){
				return -1;
			}else{
				return (aux + 1);
			}
		}

	}

	return -1;

}

int main(){

	int aux;
	cin >> n >> m >> aux;
	l.resize(n);

	for(int i = n-1; i >= 0; i--){

		l[i] = aux%10;
		aux /= 10;

	}

	cout << dfs(0) << endl;

}

#include<bits/stdc++.h>
using namespace std;
int n,d;
char s[110];
int a[110];
int tot;
int ans;
int tmp;
int main(){
	cin>>n>>d>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='1'){
			a[++tot]=i;
		}
	}
	if(tot==1){
		cout<<"0";
		return 0;
	}
	tmp=1;
	for(int i=2;i<=tot;i++){
		if(a[i]-a[tmp]>d){
			ans++;
			tmp=i-1;
		}
	}
	if(tmp==1){
		cout<<"-1";
		return 0;
	}
	if(tmp!=tot)
		ans++;
	cout<<ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
  ll n,d,cnt=0,p1=1,i;
  cin>>n>>d;
  string s;
  cin>>s;
  i=d;
  s=" "+s;
  while(1)
  {
      if(p1+d>=n && s[n]==1)
      {
          cnt++;
          break;
      }
     else if(s[p1+i]=='1')
      {
          p1+=i;
          cnt++;
          if(p1==n)
            break;
          i=d;
          continue;
      }
        i--;
     if((i+p1)<=p1)
      {
          cout<<-1;
          return 0;
      }

  }
  cout<<cnt;

}

#include <iostream>
#include<stdio.h>
#include <stdlib.h>
using namespace std;
main()
{
    int n,d,ans=0;
    cin>>n>>d;

    char arr[n];

    //for(int i=0;i<n;i++)
      //  cin>>arr[i];
    scanf("%s",arr);
    int pnt=0;
    if(arr[0]==0|| arr[n-1]==0)
        {
            cout<<-1;
            exit(2);
        }

    while(pnt+d<n)
    {
        int check=0;
        for(int i=pnt+d;i>=pnt;i--)
        {
            if(arr[i]==1)
            {
                pnt=i;
                ans++;
                check++;
                break;
            }
        }
        if(check==0)
        {
            cout<<-1;
            exit(0);
        }
    }
    if(pnt!=n-1)
        ans++;
    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); i++)
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()

void solve(string s,int n,int step)
{
	vector<int> res(n,INT_MAX);
	res[0]=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]!='1')
			continue;
		for(int j=1;j<=step;j++)
		    if((i+j)<n)
			    res[i+j]=min(res[i+j],res[i]+1);
	}
	cout<< (res[n-1]!=INT_MAX?res[n-1]:-1);
}
int main ()
{
	/*#ifndef  ONLINE_JUDGE
	    freopen("in.txt","r",stdin);
	    freopen("out.txt","w",stdout);
    #endif*/
    ios::sync_with_stdio(false);
 	cin.tie(0);
	int n,step;
	cin>>n>>step;
	string s;
	cin>>s;
	solve(s,n,step);
	return 0;
}

#include <iostream>
using namespace std;

#define For(i,a,b) for(int i=a;i<b;i++)
#define fauto(i,a) for(auto i : a)
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
int main()
{
    Fast;
    int n,d,count=0,pos=0;
    cin>>n>>d;
    char s[n+1];
    fauto(&i,s)i=getchar();
    while(pos!=n-1)
        {   int flag =1;
            for(int i=((pos+d)/n)?(n-1):(pos+d);i>pos;i--)
                {
                    if(s[i]=='1')
                    {pos =i;
                    flag =0;
                    count++;
                    break;
                    }
                }
            if(flag)
                {
                    count = -1;
                    break;
                }
        }
    cout<<count;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int cache[101];
int calc(char ar[],int n, int k) {

	if(ar[n]=='0') {
		return INT_MAX;
	}

	if(n==1) {
		return 0;
	}

	if(cache[n]!=-1) {
		return cache[n];
	}

	int mn = INT_MAX;
	for (int i=1; i<=k; i++) {
		if(n-i>=1 && ar[n-i]=='1') {
			int a = calc(ar,n-i, k);
			if(a==INT_MAX) {
				return a;
			} else {
				mn = min(mn,a+1);
			}
		}
	}
	return cache[n] = mn;
}

int main()  {
	int n,k;
	cin>>n>>k;
	char ar[101];
	for (int i=1; i<=n; i++) {
		cin>>ar[i];
	}
	int ways[101];
	for (int i=0; i<=n; i++) {
		ways[i] = INT_MAX;
	}
	ways[1] = 0;
	for (int i=2; i<=n; i++) {
		for (int j=1; j<=k; j++) {
			if(i-j>=1 && ar[i-j]=='1') {
				ways[i] = min(ways[i], ways[i-j] + 1);
			}
		}
	}
	cout << (ways[n]==INT_MAX ? -1 : ways[n]);
	return 0;
}

#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	int d;
	cout << "please enter d" << endl;
	cin >> d;
	string s;
	cout << "please enter s" << endl;
	cin >> s;
	int n = s.length();
	vector <int> lilies;
	for (int i = 0; i< n; i++) if(s[i] == '1') lilies.push_back(i);
	int pos =0;
	int counter = 0;
	vector <int> :: iterator it;
	while(pos != n-1){
		counter ++;
		bool test;
		for (int i = pos+d;i > pos; i--){
			it = find(lilies.begin(), lilies.end(), i);
			if (it != lilies.end()){
				test = true;
				pos = i;
			}
			if (test) break;
		}
		if (!test) cout << "-1";
		if (!test) break;
	}
	if (pos == n-1) cout << counter;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define vll vector<ll>
#define mp make_pair
#define pb push_back
#define f1(i,a,n) for(ll i=a;i<n;i++)
#define f2(i,a,n) for(ll i=n;i>a;i--)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test int T; cin>>T; while(T--)
#define in(x) ll x;cin>>x
#define out(x) cout<<x
#define M 1000000007
#define line cout<<endl
/* BIRLA INSTITUTE OF TECHNOLOGY*/
int main(){
fast;
in(n);in(k);
string s;cin>>s;ll mark=0, next=1 ,jumps=0;
for(ll i=1;i<=k;i++){
   // if(mark)break;
  //  cout<<"* "<<s[i]<<mark<<endl;
    if(s[i] == '1'){mark=1; next=i;}

}
ll mark1=0;
//cout<<"initial " <<next<<endl;
if(mark){
    jumps++;
    while(next!= n-1){
        ll flag=0,temp=next;
   // cout<<"begin "<<next<<endl;
        if(next+k <= n-1){
            for(ll i=1;i<=k;i++){
              if(s[temp+i] == '1'){flag=1; next=i;}
            }
        next+=temp;
        }
        else next=n-1;
  //  cout<<"end "<<next<<endl;
    jumps++;
    if(!flag){break;mark1=1;}

  }

if(mark1)cout<<-1<<endl;
else cout<<jumps<<endl;

}
else cout<<-1<<endl;

return 0;
}

#include<bits/stdc++.h>
int main()
{
     int n,d;
     while(~scanf("%d%d",&n,&d))
     {
         char str[120],a[120];
         scanf("%s",str);
         int len=strlen(str);
         for(int i=0;i<len;i++)
         {
              a[i+1]=str[i]-'0';
         }
         if(a[len]!=1)
         {
             printf("-1\n");
             return 0;
         }
         else
         {
              int p=1,count=0;
              for(int i=1;i<=len;i++)
              {
                    for(int j=d;j>=1;j--)
                    {
                       if(a[p+j]==1)
                       {
                            p=p+j;
                            count++;
                            break;
                       }
                    }
              }
              if(p==len)
              {
                 printf("%d\n",count);
              }
              else
              {
                 printf("-1\n");
              }
         }

     }
     return 0;
}

#include <bits/stdc++.h>

using namespace std;
int n, d;

const int nmax=1e2+2;
vector<int> v[nmax];
bool visited[nmax];
string s;
int res=1e4;

void dfs(int i,int j){
    if(i==n-1) res=min(res,j);
    visited[i]=true;
    for (int k=0;k<v[i].size();k++)
        if (! visited[v[i][k]])
          dfs(v[i][k], j + 1);
    visited[i]=false;

}

int main() {

 cin>>n>>d>>s;
 for (int i=0;i<n-1;i++)
    for(int j=1;j<=d;j++){
        if (i+j>=n)continue;
        v[i].push_back(i+j);

    }
 dfs(0,0);
 if (res>100)
    cout<<-1<<endl;
 else
    cout<<res<<endl;

}