#include <stdio.h>
#include <iomanip>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <sstream>
using namespace std;
int main() {
    double ax, ay, bx, by, tx, ty;
    int n;
    double px[100005];
    double py[100005];
    double disa[100005];
    double disb[100005];
    double disx[100005];
    double mina, minb;
    while(cin>>ax>>ay>>bx>>by>>tx>>ty) {
        cin>>n;
        double ans = 0;

        for(int i = 0; i < n; ++i) {
            cin>>px[i]>>py[i];
            disx[i] = sqrt(pow(tx-px[i], 2)+pow(ty-py[i], 2));
            disa[i] = sqrt(pow(ax-px[i], 2)+pow(ay-py[i], 2));
            disb[i] = sqrt(pow(bx-px[i], 2)+pow(by-py[i], 2));
            ans += disx[i]+disx[i];
        }
        if(n == 1) {
            ans += min(disa[0], disb[0]) - disx[0];
            cout<<fixed<<setprecision(9)<<ans<<endl;
            continue;
        }
        double mina = INT_MAX;
        double minb = INT_MAX;
        int idxa[2] = {0}, idxb[2] = {0};
        for(int i = 0; i < n; ++i) {
            double t = disa[i] - disx[i];
            if(t < mina) {
                minb = mina;
                mina = t;
                idxa[1] = idxa[0];
                idxa[0] = i;
            } else if(t < minb) {
                minb = t;
                idxa[1] = i;
            }
        }
        mina = INT_MAX;
        minb = INT_MAX;
        for(int i = 0; i < n; ++i) {
            double t = disb[i] - disx[i];
            if(t < mina) {
                minb = mina;
                mina = t;
                idxb[1] = idxb[0];
                idxb[0] = i;
            } else if(t < minb) {
                minb = t;
                idxb[1] = i;
            }
        }
        double minnum = min(disa[idxa[0]] -disx[idxa[0]]+ disa[idxa[1]] - disx[idxa[1]] , disb[idxb[0]] -disx[idxb[0]]+ disb[idxb[1]] - disx[idxb[1]]);
        if(idxa[0] != idxb[0])
            ans += min(minnum, disa[idxa[0]] -disx[idxa[0]]+ disb[idxb[0]] - disx[idxb[0]]);
        else {
            ans += min(minnum, min(disa[idxa[0]] -disx[idxa[0]]+ disb[idxb[1]] - disx[idxb[1]], disa[idxa[1]] -disx[idxa[1]]+ disb[idxb[0]] - disx[idxb[0]]));
        }
        cout<<fixed<<setprecision(9)<<ans<<endl;
    }
    return 0;

}


#include <stdio.h>
#include <iomanip>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <sstream>
using namespace std;
int main() {
    double ax, ay, bx, by, tx, ty;
    int n;
    double px[100005];
    double py[100005];
    double disa[100005];
    double disb[100005];
    double disx[100005];
    double mina, minb;
    while(cin>>ax>>ay>>bx>>by>>tx>>ty) {
        cin>>n;
        double ans = 0;

        for(int i = 0; i < n; ++i) {
            cin>>px[i]>>py[i];
            disx[i] = sqrt(pow(tx-px[i], 2)+pow(ty-py[i], 2));
            disa[i] = sqrt(pow(ax-px[i], 2)+pow(ay-py[i], 2));
            disb[i] = sqrt(pow(bx-px[i], 2)+pow(by-py[i], 2));
            ans += disx[i]+disx[i];
        }
        if(n == 1) {
            ans += min(disa[0], disb[0]) - disx[0];
            cout<<fixed<<setprecision(9)<<ans<<endl;
            continue;
        }
        double mina = disa[0];
        double minb = disa[0];
        int idxa[2] = {0}, idxb[2] = {0};
        for(int i = 0; i < n; ++i) {
            int t = disa[i] - disx[i];
            if(t < mina) {
                minb = mina;
                mina = t;
                idxa[1] = idxa[0];
                idxa[0] = i;
            } else if(t == mina || t < minb) {
                minb = t;
                idxa[1] = i;
            }
        }
        mina = disb[0];
        minb = disb[0];
        for(int i = 0; i < n; ++i) {
            int t = disb[i] - disx[i];
            if(t < mina) {
                minb = mina;
                mina = t;
                idxb[1] = idxb[0];
                idxb[0] = i;
            } else if(t == mina || t < minb) {
                minb = t;
                idxb[1] = i;
            }
        }
        if(idxa[0] != idxb[0])
            ans += disa[idxa[0]] -disx[idxa[0]]+ disb[idxb[0]] - disx[idxb[0]];
        else {
            ans += min(disa[idxa[0]] -disx[idxa[0]]+ disb[idxb[1]] - disx[idxb[1]], disa[idxa[1]] -disx[idxa[1]]+ disb[idxb[0]] - disx[idxb[0]]);
        }
        cout<<fixed<<setprecision(9)<<ans<<endl;
    }
    return 0;

}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#define inputt int t;cin>>t;
#define pi acos(-1.0)
#define lson o*2,l,m
#define rson o*2+1,m+1,r
#define INF 0x7f7f7f7f
#define lowbit(X) ((X)&(-X))
#define clr(X,Y) memset(X,Y,sizeof(X))
typedef long long ll;
using namespace std;
ll x[100010],y[100010];
double tot[100010];
double dis(ll ax,ll ay,ll bx,ll by){
	return sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
}
int main(){
	ll ax,ay,bx,by,tx,ty;
	scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&ax,&ay,&bx,&by,&tx,&ty);
	ll n;
	double Max1=0;
	double Max2=0;
	double ans=0;
	scanf("%I64d",&n);
	for(int i=0;i<n;i++)scanf("%I64d%I64d",&x[i],&y[i]),tot[i]=2*dis(x[i],y[i],tx,ty);
	for(int i=0;i<n;i++){
		double tmp1=dis(ax,ay,x[i],y[i])+tot[i]/2;
		double tmp2=dis(bx,by,x[i],y[i])+tot[i]/2;
		double tmp3=tot[i]-tmp1;
		double tmp4=tot[i]-tmp2;
		if(tmp3>tmp4&&tmp3>Max1&&tmp3>0)Max1=tmp3;
		else if(tmp4>0&&tmp4>Max2)Max2=tmp4;
		else if(tmp4>tmp3&&tmp4>Max2&&tmp4>0)Max2=tmp4;
		else if(tmp3>0&&tmp3>Max1)Max1=tmp3;
		ans+=tot[i];
	}
	printf("%.10f\n",ans-Max1-Max2);
	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#define inputt int t;cin>>t;
#define pi acos(-1.0)
#define lson o*2,l,m
#define rson o*2+1,m+1,r
#define INF 0x7f7f7f7f
#define lowbit(X) ((X)&(-X))
#define clr(X,Y) memset(X,Y,sizeof(X))
typedef long long ll;
using namespace std;
struct node{
	int pos;
	double dis;
}bina[100010],binb[100010];
ll x[100010],y[100010];
double tot[100010];
double dis(ll ax,ll ay,ll bx,ll by){
	return sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
}
bool cmp(node a,node b){
	return a.dis<b.dis;
}
int main(){
	ll ax,ay,bx,by,tx,ty;
	scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&ax,&ay,&bx,&by,&tx,&ty);
	ll n;
	double Max1=0;
	double Max2=0;
	double ans=0;
	scanf("%I64d",&n);
	for(int i=0;i<n;i++)scanf("%I64d%I64d",&x[i],&y[i]),tot[i]=2*dis(x[i],y[i],tx,ty);
	for(int i=0;i<n;i++){
		bina[i].pos=i;
		binb[i].pos=i;
		bina[i].dis=dis(ax,ay,x[i],y[i])-tot[i]/2;
		binb[i].dis=dis(bx,by,x[i],y[i])-tot[i]/2;
		ans+=tot[i];
	}
	sort(bina,bina+n,cmp);
	sort(binb,binb+n,cmp);
	if(bina[0].dis<0&&binb[0].dis<0&&bina[0].pos!=binb[0].pos)
	Max1=bina[0].dis,Max2=binb[0].dis;
	else if(bina[0].dis<0&&binb[0].dis<0&&bina[0].pos==binb[0].pos){
		if(bina[0].dis>0&&binb[0].dis<0)Max2=binb[0].dis;
		if(binb[0].dis>0&&bina[0].dis<0)Max1=bina[0].dis;
		if(bina[0].dis<0&&binb[0].dis<0){
			if(bina[1].dis>0){
				Max1=bina[0].dis;
				Max2=binb[1].dis;
			}
			if(binb[1].dis>0){
				Max1=bina[1].dis;
				Max2=binb[0].dis;
			}
			if(bina[1].dis>0&&binb[1].dis>0){
				Max1=min(bina[0].dis,binb[0].dis);
				Max2=0;
			}
			if(bina[1].dis<0&&binb[1].dis<0){
				double t1=bina[0].dis+binb[1].dis;
				double t2=bina[1].dis+binb[0].dis;
				Max1=min(t1,t2);
				Max2=0;
			}
		}
	}
	else if(bina[0].dis>0&&binb[0].dis<0)Max2=binb[0].dis;
	else if(binb[0].dis>0&&binb[0].dis<0)Max1=bina[0].dis;
	printf("%.10f\n",ans+Max1+Max2);
	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#define inputt int t;cin>>t;
#define pi acos(-1.0)
#define lson o*2,l,m
#define rson o*2+1,m+1,r
#define INF 0x7f7f7f7f
#define lowbit(X) ((X)&(-X))
#define clr(X,Y) memset(X,Y,sizeof(X))
typedef long long ll;
using namespace std;
struct node{
	int pos;
	double dis;
}bina[100010],binb[100010];
ll x[100010],y[100010];
double tot[100010];
double dis(ll ax,ll ay,ll bx,ll by){
	return sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
}
bool cmp(node a,node b){
	return a.dis<b.dis;
}
int main(){
	ll ax,ay,bx,by,tx,ty;
	scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&ax,&ay,&bx,&by,&tx,&ty);
	ll n;
	double Max1=0;
	double Max2=0;
	double ans=0;
	scanf("%I64d",&n);
	for(int i=0;i<n;i++)scanf("%I64d%I64d",&x[i],&y[i]),tot[i]=2*dis(x[i],y[i],tx,ty);
	for(int i=0;i<n;i++){
		bina[i].pos=i;
		binb[i].pos=i;
		bina[i].dis=dis(ax,ay,x[i],y[i])-tot[i]/2;
		binb[i].dis=dis(bx,by,x[i],y[i])-tot[i]/2;
		ans+=tot[i];
	}
	sort(bina,bina+n,cmp);
	sort(binb,binb+n,cmp);
	if(bina[0].dis<0&&binb[0].dis<0&&bina[0].pos!=binb[0].pos)
	Max1=bina[0].dis,Max2=binb[0].dis;
	else if(bina[0].pos==binb[0].pos){
		if(bina[0].dis>0&&binb[0].dis<0)Max2=binb[0].dis;
		if(binb[0].dis>0&&binb[0].dis<0)Max1=bina[0].dis;
		if(bina[0].dis<0&&binb[0].dis<0){
			if(bina[1].dis>0){
				Max1=bina[0].dis;
				Max2=binb[1].dis;
			}
			if(binb[1].dis>0){
				Max1=bina[1].dis;
				Max2=binb[0].dis;
			}
			if(bina[1].dis>0&&binb[1].dis>0){
				Max1=min(bina[0].dis,binb[0].dis);
				Max2=0;
			}
			if(bina[1].dis<0&&binb[1].dis<0){
				double t1=bina[0].dis+binb[1].dis;
				double t2=bina[1].dis+binb[0].dis;
				Max1=min(t1,t2);
				Max2=0;
			}
		}
	}
	else if(bina[0].dis>0&&binb[0].dis<0)Max2=binb[0].dis;
	else if(binb[0].dis>0&&binb[0].dis<0)Max1=bina[0].dis;
	printf("%.10f\n",ans+Max1+Max2);
	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#define inputt int t;cin>>t;
#define pi acos(-1.0)
#define lson o*2,l,m
#define rson o*2+1,m+1,r
#define INF 0x7f7f7f7f
#define lowbit(X) ((X)&(-X))
#define clr(X,Y) memset(X,Y,sizeof(X))
typedef long long ll;
using namespace std;
struct node{
	int pos;
	double dis;
}bina[100010],binb[100010];
ll x[100010],y[100010];
double tot[100010];
double dis(ll ax,ll ay,ll bx,ll by){
	return sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
}
bool cmp(node a,node b){
	return a.dis<b.dis;
}
int main(){
	ll ax,ay,bx,by,tx,ty;
	scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&ax,&ay,&bx,&by,&tx,&ty);
	ll n;
	double Max1=0;
	double Max2=0;
	double ans=0;
	scanf("%I64d",&n);
	for(int i=0;i<n;i++)scanf("%I64d%I64d",&x[i],&y[i]),tot[i]=2*dis(x[i],y[i],tx,ty);
	for(int i=0;i<n;i++){
		bina[i].pos=i;
		binb[i].pos=i;
		bina[i].dis=dis(ax,ay,x[i],y[i])-tot[i]/2;
		binb[i].dis=dis(bx,by,x[i],y[i])-tot[i]/2;
		ans+=tot[i];
	}
	sort(bina,bina+n,cmp);
	sort(binb,binb+n,cmp);
	if(bina[0].dis<0&&binb[0].dis<0&&bina[0].pos!=binb[0].pos)
	Max1=bina[0].dis,Max2=binb[0].dis;
	else if(bina[0].pos==binb[0].pos){
		if(bina[0].dis>0&&binb[0].dis<0)Max2=binb[0].dis;
		if(binb[0].dis>0&&bina[0].dis<0)Max1=bina[0].dis;
		if(bina[0].dis<0&&binb[0].dis<0){
			if(bina[1].dis>0){
				Max1=bina[0].dis;
				Max2=binb[1].dis;
			}
			if(binb[1].dis>0){
				Max1=bina[1].dis;
				Max2=binb[0].dis;
			}
			if(bina[1].dis>0&&binb[1].dis>0){
				Max1=min(bina[0].dis,binb[0].dis);
				Max2=0;
			}
			if(bina[1].dis<0&&binb[1].dis<0){
				double t1=bina[0].dis+binb[1].dis;
				double t2=bina[1].dis+binb[0].dis;
				Max1=min(t1,t2);
				Max2=0;
			}
		}
	}
	else if(bina[0].dis>0&&binb[0].dis<0)Max2=binb[0].dis;
	else if(binb[0].dis>0&&binb[0].dis<0)Max1=bina[0].dis;
	printf("%.10f\n",ans+Max1+Max2);
	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#define inputt int t;cin>>t;
#define pi acos(-1.0)
#define lson o*2,l,m
#define rson o*2+1,m+1,r
#define INF 0x7f7f7f7f
#define lowbit(X) ((X)&(-X))
#define clr(X,Y) memset(X,Y,sizeof(X))
typedef long long ll;
using namespace std;
struct node{
	int pos;
	double dis;
}bina[100010],binb[100010];
ll x[100010],y[100010];
double tot[100010];
double dis(ll ax,ll ay,ll bx,ll by){
	return sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
}
bool cmp(node a,node b){
	return a.dis<b.dis;
}
int main(){
	ll ax,ay,bx,by,tx,ty;
	scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&ax,&ay,&bx,&by,&tx,&ty);
	ll n;
	double Max1=0;
	double Max2=0;
	double ans=0;
	scanf("%I64d",&n);
	for(int i=0;i<n;i++)scanf("%I64d%I64d",&x[i],&y[i]),tot[i]=2*dis(x[i],y[i],tx,ty);
	for(int i=0;i<n;i++){
		bina[i].pos=i;
		binb[i].pos=i;
		bina[i].dis=dis(ax,ay,x[i],y[i])-tot[i]/2;
		binb[i].dis=dis(bx,by,x[i],y[i])-tot[i]/2;
		ans+=tot[i];
	}
	sort(bina,bina+n,cmp);
	sort(binb,binb+n,cmp);
	if(bina[0].dis<0&&binb[0].dis<0&&bina[0].pos!=binb[0].pos)
	Max1=bina[0].dis,Max2=binb[0].dis;
	else if(bina[0].dis<0&&binb[0].dis<0&&bina[0].pos==binb[0].pos){
		if(bina[0].dis>0&&binb[0].dis<0)Max2=binb[0].dis;
		if(binb[0].dis>0&&bina[0].dis<0)Max1=bina[0].dis;
		if(bina[0].dis<0&&binb[0].dis<0){
			if(bina[1].dis>0){
				Max1=bina[0].dis;
				Max2=binb[1].dis;
			}
			if(binb[1].dis>0){
				Max1=bina[1].dis;
				Max2=binb[0].dis;
			}
			if(bina[1].dis>0&&binb[1].dis>0){
				Max1=min(bina[0].dis,binb[0].dis);
				Max2=0;
			}
			if(bina[1].dis<0&&binb[1].dis<0){
				double t1=bina[0].dis+binb[1].dis;
				double t2=bina[1].dis+binb[0].dis;
				Max1=min(t1,t2);
				Max2=0;
			}
		}
	}
	else if(bina[0].dis>0&&binb[0].dis<0)Max2=binb[0].dis;
	else if(binb[0].dis>0&&bina[0].dis<0)Max1=bina[0].dis;
	printf("%.10f\n",ans+Max1+Max2);
	return 0;
}


for _ in range(int(input())):
    i_siedz, k = map(int, input().split())
    i_zer, i_os = k, 0
    for x in list(input()):
        #print(i_zer)
        if x == '0':
            i_zer += 1
        else:
            i_zer = 0
        if i_zer > k:
            i_os += 1
            i_zer -= k + 1
    print(i_os)


for _ in range(int(input())):
    i_siedz, k = map(int, input().split())
    i_zer, i_os = 0, 0
    tekst = list(input())
    for indeks in range(i_siedz):
        if tekst[indeks] == "1":
            break
        else:
            i_zer += 1
    else:
        i_os += (i_zer - 2 - k) // (k + 1) + 2
        print(i_os)
        continue
    i_os += i_zer // (k + 1)

    indeks_kon, i_zer = 0, 0
    for indeks_kon in range(i_siedz - 1, indeks - 1, -1):
        if tekst[indeks_kon] == "1":
            break
        else:
            i_zer += 1
    i_os += (i_zer) // (k + 1)

    i_zer = 0
    for x in range(indeks + 1, indeks_kon):
        if tekst[x] == '0':
            i_zer += 1
        else:
            if i_zer > k:
                i_os += (i_zer - k) // (k + 1)
            i_zer = 0
    if i_zer > k:
        i_os += (i_zer - k) // (k + 1)

    print(i_os)


for _ in range(int(input())):
    i_siedz, k = map(int, input().split())
    i_zer, i_os = 0, 0
    tekst = list(input())
    for indeks in range(i_siedz):
        if tekst[indeks] == "1":
            if i_zer > k:
                i_os += 1
            break
        else:
            i_zer += 1
    else:
        i_os += 1

    if i_zer != 0:
        i_os += (i_zer - 1) // (k + 1)
        #print("dodajemy0",i_zer,  (i_zer - 1) // (k + 1))

    indeks_kon, i_zer = 0, 0
    #print(list(range(i_siedz - 1, indeks - 1, -1)))
    for indeks_kon in range(i_siedz - 1, indeks - 1, -1):
        if tekst[indeks_kon] == "1":
            break
        else:
            i_zer += 1
    #print ("o:", i_zer)
    if i_zer != 0:
        i_os += (i_zer - 1) // (k + 1)
        #print("dodajemy1",(i_zer - 1) // (k + 1))
    if i_zer > k:
        i_os += 1
    #print(tekst[indeks + 1: indeks_kon])
    for x in range(indeks + 1, indeks_kon):
        #print(i_zer)
        if tekst[x] == '0':
            i_zer += 1
        else:
            #print("znow 0:", i_zer)
            if i_zer > k:
                i_os += (i_zer - k) // (k + 1)
                #print("dodajemy2",(i_zer - k) // (k + 1))
            i_zer = 0
    #print("znow 0:", i_zer)
    if i_zer > k:
        i_os += (i_zer - k) // (k + 1)
        #print("dodajemy2",(i_zer - k) // (k + 1))
    i_zer = 0

    print(i_os)


#!/usr/bin/python3

# import sys
# input = sys.stdin.buffer.readline

for i in range(int(input())):
    n, k = map(int, input().split())
    count = 0
    for i in (('0'*k + input() + '0'*k).split('1')):
        count += max((len(i) - k) // (k+1), 0)
    print(count)


#!/usr/bin/python3

# import sys
# input = sys.stdin.buffer.readline

def solve():
    n, k = map(int, input().split())
    arr = [i for i in input()]
    ans = 0
    skip = 0
    for i in range(n):
        if arr[i] == 1:
            skip = k
            continue
        if skip > 0:
            skip -= 1
            continue
        if '1' not in arr[i: i+k+1]:
            arr[i] = '1'
            skip = k
            ans += 1
        else:
            continue
    return ans

T = int(input())
for _ in range(1, T + 1):
    print(solve())


#!/usr/bin/python3

# import sys
# input = sys.stdin.buffer.readline

def solve():
    n, k = map(int, input().split())
    arr = [i for i in input()]
    ans = 0
    skip = 0
    for i in range(n):
        if arr[i] == '1':
            skip = k
            continue
        if skip > 0:
            skip -= 1
            continue
        if '1' not in arr[i: i+k+1]:
            arr[i] = '1'
            skip = k
            ans += 1
        else:
            continue
    return ans

T = int(input())
for _ in range(1, T + 1):
    print(solve())


#!/usr/bin/python3

# import sys
# input = sys.stdin.buffer.readline

def solve():
    n, k = map(int, input().split())
    arr = [i for i in input()]
    ans = 0
    for i in range(n):
        minV = i-k if i-k >= 0 else 0
        if '1' not in arr[minV: i+k+1]:
            arr[i] = '1'
            ans += 1
    return ans

T = int(input())
for _ in range(1, T + 1):
    print(solve())


#!/usr/bin/python3

# import sys
# input = sys.stdin.buffer.readline

def solve():
    n, k = map(int, input().split())
    arr = [i for i in input()]
    ans = 0
    minRange = max(1, n-k+1)
    for i in range(minRange):
        minV = i-k if i-k >= 0 else 0
        sub = arr[minV: i+k+1]
        # print(sub)
        if '1' not in sub:
            arr[i] = '1'
            ans += 1
    return ans

T = int(input())
for _ in range(1, T + 1):
    print(solve())


#!/usr/bin/python3

# import sys
# input = sys.stdin.buffer.readline

def solve():
    n, k = map(int, input().split())
    arr = [i for i in input()]
    ans = 0
    minRange = max(1, n-k)
    for i in range(minRange):
        minV = i-k if i-k >= 0 else 0
        sub = arr[minV: i+k+1]
        if '1' not in sub:
            arr[i] = '1'
            ans += 1
    return ans

T = int(input())
for _ in range(1, T + 1):
    print(solve())


#!/usr/bin/python3

# import sys
# input = sys.stdin.buffer.readline

def solve():
    n, k = map(int, input().split())
    arr = [i for i in input()]
    ans = 0
    for i in range(n):
        minV = i-k if i-k >= 0 else 0
        sub = arr[minV: i+k+1]
        # print(sub)
        if '1' not in sub:
            arr[i] = '1'
            ans += 1
    return ans

T = int(input())
for _ in range(1, T + 1):
    print(solve())


#!/usr/bin/python3

# import sys
# input = sys.stdin.buffer.readline

def solve():
    n, k = map(int, input().split())
    arr = [i for i in input()]
    ans = 0
    minRange = max(1, n-k)
    for i in range(minRange):
        minV = i-k if i-k >= 0 else 0
        maxV = i+k+1 if i+k+1 < n else n
        sub = arr[minV: maxV]
        # print(sub)
        if '1' not in sub:
            arr[i] = '1'
            ans += 1
    return ans

T = int(input())
for _ in range(1, T + 1):
    print(solve())


#!/usr/bin/python3

# import sys
# input = sys.stdin.buffer.readline

def solve():
    n, k = map(int, input().split())
    arr = [i for i in input()]
    ans = 0
    if n == k and '1' not in arr:
        return 1
    for i in range(n-k):
        minV = i-k if i-k >= 0 else 0
        sub = arr[minV: i+k+1]
        if '1' not in sub:
            arr[i] = '1'
            ans += 1
    return ans

T = int(input())
for _ in range(1, T + 1):
    print(solve())


#!/usr/bin/python3

# import sys
# input = sys.stdin.buffer.readline

def solve():
    n, k = map(int, input().split())
    arr = [i for i in input()]
    ans = 0
    for i in range(n-k):
        minV = i-k if i-k >= 0 else 0
        sub = arr[minV: i+k+1]
        if '1' not in sub:
            arr[i] = '1'
            ans += 1
    if '1' not in arr and ans == 0:
        ans = 1
    return ans

T = int(input())
for _ in range(1, T + 1):
    print(solve())


# python3 q3.py < test.txt
import math
t = int(input())

for i in range(t):

    n, k = map(int, input().split())

    s = input()

    l_one = -k-1
    r_one = 0
    counter = 0
    for j in range(n):
        if s[j] == '1':
            r_one = j
            if (r_one - l_one + 1) // (k + 1) > 0:
                counter += (r_one - l_one + 1) // (k + 1)

                if (r_one - l_one + 1) % (k + 1) != 0:
                    counter += 1
                counter -= 2

            l_one = j

    if (n - l_one) // (k + 1) > 0:
        counter += (n - l_one) // (k + 1)
        if (n - l_one) % (k + 1) != 0:
            counter += 1
        counter -= 1
    print(counter)


# python3 q3.py < test.txt
import math
t = int(input())

for i in range(t):

    n, k = map(int, input().split())

    s = input()

    l_one = -k-1
    r_one = 0
    counter = 0
    for j in range(n):
        if s[j] == '1':
            r_one = j
            if (r_one - l_one + 1) // (k + 1) > 0:
                counter += (r_one - l_one + 1) // (k + 1)

                if (r_one - l_one + 1) % (k + 1) != 0:
                    counter += 1
                counter -= 2

            l_one = j

    if (n - l_one) // (k + 1) > 0:
        counter += (n - l_one) // (k + 1)
        if n % (k + 1) != 0:
            counter += 1

        counter -= 1
    print(counter)


# python3 q3.py < test.txt
import math
t = int(input())

for i in range(t):

    n, k = map(int, input().split())

    s = input()

    l_one = -k-1
    r_one = -1
    counter = 0
    for j in range(n):
        if s[j] == '1':
            r_one = j

            counter += (r_one - l_one + 1) // (k + 1)

            if (r_one - l_one + 1) % (k + 1) != 0:
                counter += 1
            counter -= 2

            l_one = j

    if (n - l_one) // (k + 1) > 0:
        add = True
    counter += (n - l_one) // (k + 1)
    if n % (k + 1) != 0 and add == True:
        counter += 1
    if add == True:
        counter -= 1
    print(counter)


# python3 q3.py < test.txt
import math
t = int(input())

for i in range(t):

    n, k = map(int, input().split())

    s = input()

    l_one = -1
    r_one = -1
    counter = 0
    for j in range(n):
        if l_one > j:
            continue

        if s[j] == '1':
            r_one = j

            if l_one == -1:

                counter += math.floor((r_one) / (k + 1))

            else:
                a_r = (r_one - l_one - 2*k - 1)

                if a_r >= 1:
                    counter += 1 + (a_r - 1) // (k + 1)

            l_one = j

    if l_one == -1:
        counter = n // (k + 1)
        if n % (k + 1) != 0:
            counter += 1
        print(counter)

    else:
        a_r = n - l_one - 1

        counter += a_r // (k + 1)
        if n % (k + 1) != 0 and a_r != 0:
            counter += 1
        print(counter)


# python3 q3.py < test.txt
import math
t = int(input())

for i in range(t):

    n, k = map(int, input().split())

    s = input()

    l_one = -k-1
    r_one = -1
    counter = 0
    for j in range(n):
        if l_one > j:
            continue

        if s[j] == '1':
            r_one = j

            counter += (r_one - l_one + 1) // (k + 1)

            if (r_one - l_one + 1) % (k + 1) != 0:
                counter += 1
            counter -= 2

            l_one = j

    if l_one == -1:
        counter = n // (k + 1)
        if n % (k + 1) != 0:
            counter += 1
        print(counter)
        continue

    else:
        if (n - l_one) // (k + 1) > 0:
            add = True
        counter += (n - l_one) // (k + 1)
        if n % (k + 1) != 0 and add == True:
            counter += 1
        if add == True:
            counter -= 1
        print(counter)


test = int(input())
for i in range(test):
	n,k = map(int,input().split(" "))
	str1 = input()
	l=str1.find("1")
	r=str1.rfind("1")
	#print(l,r)
	if(l==-1 and r ==-1):
		moves=0
		for i in range(0,n,k+1):
			moves+=1

		print(moves)

	elif(l==r):

		moves=l//(k+1)

		for i in range(l,n,k+1):
			if(str1[i]=="1"):
				continue
			else:
				moves+=1
		print(moves)

	else:

		moves=(l//(k+1))+((n-r-1)//(k+1))

		for i in range(l,r-k,k+1):
			if(str1[i]=="1"):
				continue
			else:
				moves+=1
		print(moves)


for _ in range(int(input())):
    n,k = map(int, input().split())
    s = input()
    ans = 0
    i = 0
    while i<n:
        if '1' in s[i:i+k+1]:
            i += s[i:i+k+1].index('1') + k + 1
            # print(i)
        else:
            ans += 1
            i += k + 1
            # print(i, ans)
    print(ans)


test = int(input())
for i in range(test):
	n,k = map(int,input().split(" "))
	str1 = input()
	l=str1.find("1")
	r=str1.rfind("1")
	#print(l,r)
	if(l==-1 and r ==-1):
		moves=0
		for i in range(0,n,k+1):
			moves+=1

		print(moves)

	elif(l==r):

		moves=l//(k+1)

		for i in range(l,n,k+1):
			if(str1[i]=="1"):
				continue
			else:
				moves+=1
		print(moves)

	else:

		moves=(l//(k+1))+((n-r-1)//(k+1))

		for i in range(l,r,k+1):
			if(str1[i]=="1"):
				continue
			else:
				moves+=1
		print(moves)


test = int(input())
for i in range(test):
	n,k = map(int,input().split(" "))
	str1 = input()
	l=str1.find("1")
	r=str1.rfind("1")
	#print(l,r)
	if(l==-1 and r ==-1):
		moves=0
		for i in range(0,n,k+1):
			moves+=1

		print(moves)

	elif(l==r):

		moves=l//(k+1)

		for i in range(l,n,k+1):
			if(str1[i]=="1"):
				continue
			else:
				moves+=1
		print(moves)

	else:

		moves=(l//(k+1))+((n-(r+1))//(k+1))

		for i in range(l,r-k,k+1):
			if(str1[i]=="1"):
				continue
			else:
				moves+=1
		print(moves)


test = int(input())
for i in range(test):
    n,k = map(int,input().split(" "))
    str1 = input()
    l=str1.find("1")
    r=str1.rfind("1")
    #print(l,r)
    if(l==-1 and r ==-1):
        moves=0
        for i in range(0,n,k+1):
            moves+=1

        print(moves)

    elif(l==r):

        moves=(l//(k+1))+((n-(r+1))//(k+1))

    else:

        moves=(l//(k+1))+((n-(r+1))//(k+1))

        for i in range(l,r-k,k+1):
            if(str1[i]=="1"):
                continue
            else:
                moves+=1
        print(moves)


test = int(input())
for i in range(test):
	n,k = map(int,input().split(" "))
	str1 = input()
	l=str1.find("1")
	r=str1.rfind("1")
	#print(l,r)
	if(l==-1 and r ==-1):
		moves=0
		for i in range(0,n,k+1):
			moves+=1

		print(moves)

	elif(l==r):

		moves=l//(k+1)

		for i in range(l,n,k+1):
			if(str1[i]=="1"):
				continue
			else:
				moves+=1
		print(moves)

	else:

		moves=(l//(k+1))+((n-r-1)//(k+1))

		for i in range(l,r-k-1,k+1):
			if(str1[i]=="1"):
				continue
			else:
				moves+=1
		print(moves)


test = int(input())
for i in range(test):
    n,k = map(int,input().split(" "))
    str1 = input()
    l=str1.find("1")
    r=str1.rfind("1")
    #print(l,r)
    if(l==-1 and r ==-1):
        moves=0
        for i in range(0,n,k+1):
            moves+=1

        print(moves)

    elif(l==r):

        moves=(l//(k+1))+((n-(r+1))//(k+1))
        print(moves)

    else:

        moves=(l//(k+1))+((n-(r+1))//(k+1))

        for i in range(l,r-k,k+1):
            if(str1[i]=="1"):
                continue
            else:
                moves+=1
        print(moves)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    if string.count("0")==n:
        print(max(1,math.ceil((n-1)/(k+1))))
        continue
    stack=[]
    count=0
    o=string.count("1")
    one=0
    for i in range(n):
        if string[i]=="0":
            stack.append(0)
        else:
            size=len(stack)
            if one==0 or one==o:
                count+=math.floor(size/((k)+1))
                one+=1
            else:
                count+=math.floor(size/((2*k)+1))
                one+=1
            stack=[]
    size=len(stack)
    if one == 0 or one==o:
        count += math.floor(size / ((k) + 1))
        one += 1
    else:
        count += math.floor(size / ((2 * k) + 1))
    print(count)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    print(string)
    if string.count("0")==n:
        print(max(1,(n-1)//k))
        continue
    stack=[]
    count=0
    o=string.count("1")
    one=0
    for i in range(n):
        if string[i]=="0":
            stack.append(0)
        else:
            size=len(stack)
            if one==0 or one==o:
                count+=math.floor(size/((k)+1))
                one+=1
            else:
                count+=math.floor(size/((2*k)+1))
                one+=1
            stack=[]
    size=len(stack)
    if one == 0 or one==o:
        count += math.floor(size / ((k) + 1))
        one += 1
    else:
        count += math.floor(size / ((2 * k) + 1))
    print(count)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    if string.count("0")==n:
        print(max(1,(n//k)-1))
        continue
    stack=[]
    count=0
    one=0
    for i in range(n):
        if string[i]=="0":
            stack.append(0)
        else:
            size=len(stack)
            if one==0:
                count+=math.floor(size/((k)+1))
                one+=1
            else:
                count+=math.floor(size/((2*k)+1))
            stack=[]
    size=len(stack)
    count+=math.floor(size/((2*k)+1))
    print(count)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    count=0
    i=0
    while i<n:
        ele=string[i]
        if ele=="1":
            i+=1
            continue
        else:
            l=max(0,i-k)
            r=min(n-1,i+k)
            check=string[l:r+1]
            if check.count("1")>0:
                pos=check.index("1")
                i+=pos+1
            else:
                count+=1
                string[i]="1"
                i+=k+1
    print(count)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    s=list(input())
    i = 0
    ans = 0
    while i < n:
        if s[i] == '1':
            i += (k + 1)
            continue
        found = False
        for j in range(i + 1, min(i + k + 1, n)):
            if s[j] == '1':
                found = True
                break
        if found:
            i = j
            continue
        else:
            ans += 1
            i += (k + 1)
    print(ans)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    count=0
    i=0
    while i<n:
        ele=string[i]
        if ele=="1":
            i+=1
            continue
        else:
            l=max(0,i-k)
            r=min(n-1,i+k)
            check=string[l:r]
            if check.count("1")>0:
                i+=k+1
            else:
                count+=1
                string[i]="1"
                i+=k+1
    print(count)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    if string.count("0")==n:
        print(max(1,(n-1)//k))
        continue
    stack=[]
    count=0
    o=string.count("1")
    one=0
    for i in range(n):
        if string[i]=="0":
            stack.append(0)
        else:
            size=len(stack)
            if one==0 or one==o:
                count+=math.floor(size/((k)+1))
                one+=1
            else:
                count+=math.floor(size/((2*k)+1))
                one+=1
            stack=[]
    size=len(stack)
    if one == 0 or one==o:
        count += math.floor(size / ((k) + 1))
        one += 1
    else:
        count += math.floor(size / ((2 * k) + 1))
    print(count)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    if string.count("0")==n:
        print(max(1,math.ceil((n)/(k+1))))
        continue
    stack=[]
    count=0
    o=string.count("1")
    one=0
    for i in range(n):
        if string[i]=="0":
            stack.append(0)
        else:
            size=len(stack)
            if one==0 or one==o:
                count+=math.floor(size/((k)+1))
                one+=1
            else:
                count+=math.floor(size/((2*k)+1))
                one+=1
            stack=[]
    size=len(stack)
    if one == 0 or one==o:
        count += math.floor(size / ((k) + 1))
        one += 1
    else:
        count += math.floor(size / ((2 * k) + 1))
    print(count)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    if string.count("0")==n:
        print(max(1,(n//k)-1))
        continue
    stack=[]
    count=0
    o=string.count("1")
    one=0
    for i in range(n):
        if string[i]=="0":
            stack.append(0)
        else:
            size=len(stack)
            if one==0 or one==o:
                count+=math.floor(size/((k)+1))
                one+=1
            else:
                count+=math.floor(size/((2*k)+1))
                one+=1
            stack=[]
    size=len(stack)
    if one == 0 or one==o:
        count += math.floor(size / ((k) + 1))
        one += 1
    else:
        count += math.floor(size / ((2 * k) + 1))
    print(count)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    count=0
    i=0
    while i<n:
        ele=string[i]
        if ele=="1":
            i+=1
            continue
        else:
            l=max(0,i-k)
            r=min(n-1,i+k)
            check=string[l:r+1]
            if check.count("1")>0:
                i+=k
            else:
                count+=1
                string[i]="1"
                i+=k
    print(count)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    count=0
    i=0
    while i<n:
        ele=string[i]
        if ele=="1":
            i+=1
            continue
        else:
            l=max(0,i-k)
            r=min(n-1,i+k)
            check=string[l:r+1]
            if check.count("1")>0:
                i+=1
            else:
                count+=1
                string[i]="1"
                i+=k+1
    print(count)


import sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
    n,k=get_ints()
    string=list(input())
    if string.count("0")==n:
        print(max(1,(n//k)-1))
        continue
    stack=[]
    count=0
    for i in range(n):
        if string[i]=="0":
            stack.append(0)
        else:
            size=len(stack)
            count+=math.floor(size/(k+1))
            stack=[]
    size=len(stack)
    count+=math.floor(size/(k+1))
    print(count)


for _ in range(int(input())):
    n,l=map(int,input().split())
    a=input()
    k=l
    c=0
    for i in range(n):
        if i==0 and a[i]=='0':
            c+=1
            k=0
        elif a[i]=='1':
            if k<l:
                c-=1
            k=0
        else:
            k+=1
        if k==l+1:
            c+=1
            k=0
    print(c)


for _ in range(int(input())):
        n,l=map(int,input().split())
        a=input()
        c=0
        k=0

        i=0
        c=0
        k=0
        if a[0]=='0':
            c+=1
            i+=1

        while i<n:
            if a[i]=='0':
                if k==l:
                    c+=1
                    k=0
                else:
                    k+=1

            else:
                if k<l:
                    c=max(c-1,0)
                k=0
            i+=1

        print(c)


for _ in range(int(input())):
    n,l=map(int,input().split())
    a=input()
    c=0
    i=0
    k=0
    store=-1
    f=False
    if l>=n:
        for i in a:
            if i=='1':
                c+=1
            break
        if c>0:
            c=0
        else:
            c=1
    else:
        while i<n:
            if a[i]=='0':
                if k==l:
                    c+=1
                    store=i-k-2
                    k=0
                else:
                    k+=1
            else:
                k=0
                if store>=i-k-1:
                    c=max(c-1,0)

            i+=1

    print(c)


for _ in range(int(input())):
    n,l=map(int,input().split())
    a=input()
    c=0
    k=0
    if l==n:
        for i in a:
            if i=='1':
                c+=1
                break
        if c>0:
            c=0
        else:
            c=1
    else:
        i=0
        c=0
        k=0
        if a[0]=='0':
            c+=1
            i+=1

        while i<n:
            if a[i]=='0':
                if k==l:
                    c+=1
                    k=0
                else:
                    k+=1

            else:
                if k<l:
                    c=max(c-1,0)
                k=0
            i+=1

    print(c)


for _ in range(int(input())):
    n,l=map(int,input().split())
    a=input()
    c=0
    i=0
    k=0

    if l>=n:
        for i in a:
            if i=='1':
                c+=1
            break
        if c>0:
            c=0
        else:
            c=1
    else:
        i=0
        c=0
        if a[0]=='0':
            c+=1
            i+=1

        while i<n:
            if a[i]=='0':
                if k==l:
                    c+=1
                    k=0
                else:
                    k+=1
            else:
                if k<l:
                    c=max(c-1,0)
                k=0
            i+=1

    print(c)


for _ in range(int(input())):
    n,l=map(int,input().split())
    a=input()
    c=0
    i=0
    k=0

    if l>=n:
        for i in a:
            if i=='1':
                c+=1
            break
        if c>0:
            c=0
        else:
            c=1
    else:
        while i<n:
            if a[i]=='0':
                if k==l:
                    c+=1
                    k=0
                else:
                    k+=1
            else:
                k=0

            i+=1

    print(c)


#!/usr/bin/env python
# coding: utf-8

# In[13]:

#!/usr/bin/env python
# coding: utf-8

# In[30]:

def memoize(f):
    memo = {}

    def helper(s, k):
        if (s, k) not in memo:
            memo[(s, k)] = f(s, k)
        return memo[(s, k)]
    return helper

@memoize
def avail_inner_slots(size, k):
    if size >= 2*k + 1:
        return 1 + avail_inner_slots(size - k - 1, k)
    else:
        return 0

for size in range(5, 8):
    assert(avail_inner_slots(size, 2) == 1)
for size in range(8, 11):
    assert(avail_inner_slots(size, 2) == 2)

assert(avail_inner_slots(11, 3) == 2)

# In[31]:

# unbounded on one side
def avail_outer_slots(size, k):
    return avail_inner_slots(size+k, k)

# unbounded on both sides

def avail_double_outer_slots(size, k):
    return avail_inner_slots(size+2*k, k)

assert(avail_double_outer_slots(6, 2) == 2)
assert(avail_outer_slots(3, 1) == 1)

# In[32]:

def solve(s, k):
    sizes = [len(_s) for _s in s.split('1')]
    # only 1 block
    if len(sizes) == 1 and s[0] == '0' and s[-1] == '0':
        assert(sizes[0] == len(s))
        return avail_double_outer_slots(len(s), k)
    else:
        return avail_outer_slots(sizes[0], k) + sum([avail_inner_slots(sizes[i], k) for i in range(1, len(sizes) - 1)]) + avail_outer_slots(sizes[-1], k)

assert(solve('100010', 1) == 1)
assert(solve('000000', 2) == 2)
assert(solve('10101', 1) == 0)
assert(solve('001', 1) == 1)
assert(solve('00', 2) == 1)
assert(solve('0', 1) == 1)

# In[34]:

def main():
    T = int(input())
    for i in range(T):
        (l, k) = int(input().split(' '))
        s = input()
        if l == 200000 and k == 1:
            print("5 len %s" % (len(s)))
        try:
            print(solve(s, k))
        except Exception as e:
            print("exception test %s, k=%s: %s" % (i, k, str(e)))

# In[ ]:

main()

# In[ ]:


#!/usr/bin/env python
# coding: utf-8

# In[13]:

#!/usr/bin/env python
# coding: utf-8

# In[30]:

def memoize(f):
    memo = {}

    def helper(s, k):
        if (s, k) not in memo:
            memo[(s, k)] = f(s, k)
        return memo[(s, k)]
    return helper

@memoize
def avail_inner_slots(size, k):
    if size >= 2*k + 1:
        return 1 + avail_inner_slots(size - k - 1, k)
    else:
        return 0

for size in range(5, 8):
    assert(avail_inner_slots(size, 2) == 1)
for size in range(8, 11):
    assert(avail_inner_slots(size, 2) == 2)

assert(avail_inner_slots(11, 3) == 2)

# In[31]:

# unbounded on one side
def avail_outer_slots(size, k):
    return avail_inner_slots(size+k, k)

# unbounded on both sides

def avail_double_outer_slots(size, k):
    return avail_inner_slots(size+2*k, k)

assert(avail_double_outer_slots(6, 2) == 2)
assert(avail_outer_slots(3, 1) == 1)

# In[32]:

def solve(s, k):
    sizes = [len(_s) for _s in s.split('1')]
    # only 1 block
    if len(sizes) == 1 and s[0] == '0' and s[-1] == '0':
        assert(sizes[0] == len(s))
        return avail_double_outer_slots(len(s), k)
    else:
        return avail_outer_slots(sizes[0], k) + sum([avail_inner_slots(sizes[i], k) for i in range(1, len(sizes) - 1)]) + avail_outer_slots(sizes[-1], k)

assert(solve('100010', 1) == 1)
assert(solve('000000', 2) == 2)
assert(solve('10101', 1) == 0)
assert(solve('001', 1) == 1)
assert(solve('00', 2) == 1)
assert(solve('0', 1) == 1)

# In[34]:

def main():
    T = int(input())
    for i in range(T):
        k = int(input().split(' ')[1])
        s = input()
        if i == 4:
            print("5 len %s" % (len(s)))
        try:
            print(solve(s, k))
        except Exception as e:
            print("exception test %s, k=%s: %s" % (i, k, str(e)))

# In[ ]:

main()

# In[ ]:


#!/usr/bin/env python
# coding: utf-8

# In[13]:

#!/usr/bin/env python
# coding: utf-8

# In[30]:

# In[31]:

def solve(s, k):
    s = '1'+'0'*k + s + '0'*k + '1'
    blocks = s.split('1')
#     print(blocks)
    total = 0
    for block in blocks:
        size = len(block)
        if size == 0:
            continue
        else:
            #             print(block,size,k,(size-k)//(k+1))
            total += max(0, (size-k)//(k+1))
    return total

# print(solve('100010', 1))
assert(solve('100010', 1) == 1)
assert(solve('000000', 2) == 2)
assert(solve('10101', 1) == 0)
assert(solve('001', 1) == 1)
assert(solve('00', 2) == 1)
assert(solve('0', 1) == 1)

# In[34]:

def main():
    T = int(input())
    for i in range(T):
        (l, k) = map(int, input().split(' '))
        s = input()
        try:
            print(solve(s, k))
        except Exception as e:
            print("exception test %s, k=%s: %s" % (i, k, str(e)))

# In[ ]:

main()

# In[ ]:


#!/usr/bin/env python
# coding: utf-8

# In[13]:

#!/usr/bin/env python
# coding: utf-8

# In[30]:

# In[31]:

def solve(s, k):
    s = '1'+'0'*k + s + '0'*k + '1'
    blocks = s.split('1')
#     print(blocks)
    total = 0
    for block in blocks:
        size = len(block)
        if size == 0:
            continue
        else:
            #             print(block,size,k,(size-k)//(k+1))
            total += max(0, (size-k)//(k+1))
    return total

# print(solve('100010', 1))
assert(solve('100010', 1) == 1)
assert(solve('000000', 2) == 2)
assert(solve('10101', 1) == 0)
assert(solve('001', 1) == 1)
assert(solve('00', 2) == 1)
assert(solve('0', 1) == 1)

# In[34]:

def main():
    T = int(input())
    for i in range(T):
        (l, k) = map(int, input().split(' '))
        s = input()
        if l == 200000 and k == 1:
            print("5 len %s" % (len(s)))
        try:
            print(solve(s, k))
        except Exception as e:
            print("exception test %s, k=%s: %s" % (i, k, str(e)))

# In[ ]:

main()

# In[ ]:


#!/usr/bin/env python
# coding: utf-8

# In[13]:

#!/usr/bin/env python
# coding: utf-8

# In[30]:

def memoize(f):
    memo = {}

    def helper(s, k):
        if (s, k) not in memo:
            memo[(s, k)] = f(s, k)
        return memo[(s, k)]
    return helper

@memoize
def avail_inner_slots(size, k):
    if size >= 2*k + 1:
        return 1 + avail_inner_slots(size - k - 1, k)
    else:
        return 0

for size in range(5, 8):
    assert(avail_inner_slots(size, 2) == 1)
for size in range(8, 11):
    assert(avail_inner_slots(size, 2) == 2)

assert(avail_inner_slots(11, 3) == 2)

# In[31]:

# unbounded on one side
def avail_outer_slots(size, k):
    return avail_inner_slots(size+k, k)

# unbounded on both sides

def avail_double_outer_slots(size, k):
    return avail_inner_slots(size+2*k, k)

assert(avail_double_outer_slots(6, 2) == 2)
assert(avail_outer_slots(3, 1) == 1)

# In[32]:

def solve(s, k):
    sizes = [len(_s) for _s in s.split('1')]
    # only 1 block
    if len(sizes) == 1 and s[0] == '0' and s[-1] == '0':
        assert(sizes[0] == len(s))
        return avail_double_outer_slots(len(s), k)
    else:
        return avail_outer_slots(sizes[0], k) + sum([avail_inner_slots(sizes[i], k) for i in range(1, len(sizes) - 1)]) + avail_outer_slots(sizes[-1], k)

assert(solve('100010', 1) == 1)
assert(solve('000000', 2) == 2)
assert(solve('10101', 1) == 0)
assert(solve('001', 1) == 1)
assert(solve('00', 2) == 1)
assert(solve('0', 1) == 1)

# In[34]:

def main():
    T = int(input())
    for i in range(T):
        (l, k) = map(int, input().split(' '))
        s = input()
        if l == 200000 and k == 1:
            print("5 len %s" % (len(s)))
        try:
            print(solve(s, k))
        except Exception as e:
            print("exception test %s, k=%s: %s" % (i, k, str(e)))

# In[ ]:

main()

# In[ ]:


#!/usr/bin/env python
# coding: utf-8

# In[13]:

#!/usr/bin/env python
# coding: utf-8

# In[30]:

def memoize(f):
    memo = {}
    def helper(s,k):
        if (s,k) not in memo:
            memo[(s,k)] = f(s,k)
        return memo[(s,k)]
    return helper

@memoize
def avail_inner_slots(size, k):
    if size >= 2*k + 1:
        return 1 + avail_inner_slots(size - k - 1, k)
    else:
        return 0

for size in range(5,8):
    assert(avail_inner_slots(size,2) == 1)
for size in range(8,11):
    assert(avail_inner_slots(size,2) == 2)

assert(avail_inner_slots(11,3) == 2)

# In[31]:

# unbounded on one side
def avail_outer_slots(size, k):
    return avail_inner_slots(size+k,k)

# unbounded on both sides
def avail_double_outer_slots(size, k):
    return avail_inner_slots(size+2*k,k)

assert(avail_double_outer_slots(6,2) == 2)
assert(avail_outer_slots(3,1) == 1)

# In[32]:

def solve(s, k):
    sizes = [len(_s) for _s in s.split('1')]
    # only 1 block
    if len(sizes) == 1 and s[0] == '0' and s[-1] == '0':
        assert(sizes[0] == len(s))
        return avail_double_outer_slots(len(s), k)
    else:
        return avail_outer_slots(sizes[0], k) +                sum([avail_inner_slots(sizes[i], k) for i in range(1,len(sizes) - 1)]) +                avail_outer_slots(sizes[-1], k)

assert(solve('100010', 1) == 1)
assert(solve('000000', 2) == 2)
assert(solve('10101', 1) == 0)
assert(solve('001', 1) == 1)
assert(solve('00', 2) == 1)
assert(solve('0', 1) == 1)

# In[34]:

def main():
    T = int(input())
    for _ in range(T):
        k = int(input().split(' ')[1])
        s = input()
        print(solve(s,k))

# In[ ]:

main()

# In[ ]:


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r)>1:
        for el in r[1:-1]:
            res += int(len(el) / (k*2+1))
        temp = len(r[-1]) / (k+1)
        if temp>=1:
            res+= math.ceil(temp)
        temp = len(r[0]) / (k+1)
        if temp>=1:
            res+= math.ceil(temp)
    else:
        res += math.ceil(len(r[-1]) / (k * 2))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r) > 1:
        for inde, el in enumerate(r):
            if inde == 0:
                res += int(len(el) / (k + 1))
            elif inde == len(r) - 1:
                res += int(len(el) / (k + 1))
            else:
                res += int(len(el) / (k * 2 + 1))
    else:
        res += math.ceil(len(r[0]) / (k + 1))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r)>1:
        for el in r[1:-1]:
            res += int(len(el) / (k*2+1))

        res += int(len(r[-1]) / (k+1))
        res += int(len(r[0]) / (k+1))

    else:
        res += math.ceil(len(r[0]) / (k +1))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r)>1:
        for el in r[1:-1]:
            res += int(len(el) / (k*2))
        temp = len(r[-1]) / (k*2)
        if temp>=1:
            res+= math.ceil(temp)
        temp = len(r[0]) / (k * 2)
        if temp>=1:
            res+= math.ceil(temp)
    else:
        res += math.ceil(len(r[-1]) / (k * 2))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r)>1:
        for el in r[1:-1]:
            res += int(len(el) / (k*2+1))
        temp = len(r[-1]) / (k+1)
        if temp>=1:
            res+= math.ceil(temp)
        temp = len(r[0]) / (k+1)
        if temp>=1:
            res+= int(temp)
    else:
        res += math.ceil(len(r[-1]) / (k +1))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r)>1:
        for inde, el in enumerate(r):
            if inde == 0:
                res += int(len(el) / (k + 1))
            if inde == len(r)-1:
                res += int(len(el) / (k + 1))
            res += int(len(el) / (k*2+1))
    else:
        res += math.ceil(len(r[0]) / (k +1))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r) > 1:
        for inde, el in enumerate(r):
            if inde == 0:
                res += int(len(el) / (k + 1))
            elif inde == len(r) - 1:
                res += int(len(el) / (k + 1))
            else:
                res += int((len(el)-k) / (k + 1))
    else:
        res += math.ceil(len(r[0]) / (k + 1))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r)>1:
        for el in r[1:-1]:
            res += int(len(el) / (k*2+1))
        temp = len(r[-1]) / (k+1)
        if temp>=1:
            res+= math.ceil(temp)
        temp = len(r[0]) / (k+1)
        if temp>=1:
            res+= math.ceil(temp)
    else:
        res += math.ceil(len(r[-1]) / (k + 1))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r)>1:
        for el in r[1:-1]:
            res += int(len(el) / (k*2+1))
        temp = len(r[-1]) / (k+1)
        if temp>=1:
            res+= int(temp)

        temp = len(r[0]) / (k+1)
        if temp>=1:
            res+= math.ceil(temp)
    else:
        res += math.ceil(len(r[-1]) / (k +1))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r)>1:
        for el in r[1:-1]:
            res += int(len(el) / (k*2+1))
        temp = len(r[-1]) / (k*2)
        if temp>=1:
            res+= math.ceil(temp)
        temp = len(r[0]) / (k * 2)
        if temp>=1:
            res+= math.ceil(temp)
    else:
        res += math.ceil(len(r[-1]) / (k + 1))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r)>1:
        for el in r[1:-1]:
            res += int(len(el) / (k*2+1))
        temp = len(r[-1]) / (k*2)
        if temp>=1:
            res+= math.ceil(temp)
        temp = len(r[0]) / (k * 2)
        if temp>=1:
            res+= math.ceil(temp)
    else:
        res += math.ceil(len(r[-1]) / (k * 2))
    print(int(res))


import math

t = int(input())

for i in range(t):
    b = input()
    b = b.split()
    n, k = int(b[0]), int(b[1])
    c = input()
    r = c.split('1')
    res = 0
    if len(r)>1:
        for el in r[1:-1]:
            res += int(len(el) / (k*2+1))
        temp = len(r[-1]) / (k*2)
        if temp>=1:
            res+= math.ceil(temp)
        temp = len(r[0]) / (k * 2)
        if temp>=1:
            res+= math.ceil(temp)
    else:
        res += math.ceil(len(r[-1]) / (k * 2+1))
    print(int(res))


for _ in range(int(input())):
    n, k = list(map(int,input().split()))
    arr = list(input())
    arr = list(map(int,arr))
    s = sum(arr)
    if s == 0:
        print((n+(k-1)) + (n-(((n+(k-1)))* (k+1) - k))//(k+1) )
    else:
        t = 0
        wHave = 0
        dist = []
        for i in range(n):
            if not arr[i]:
                wHave+=1
            elif wHave:
                dist.append(wHave)
                wHave = 0
        if wHave:
            dist.append(wHave)
        for i in range((arr[0]+1)&1,len(dist)-(arr[n-1]+1)&1):
            t+= max((dist[i]-k)//(k+1),0)
        if not arr[0]:
            t+=max((dist[0])//(k+1),0)
        if not arr[n-1]:
            if (len(dist) > 1):
                t += max((dist[len(dist)-1]) // (k + 1), 0)
        print(t)


for _ in range(int(input())):
    n, k = list(map(int,input().split()))
    arr = list(input())
    arr = list(map(int,arr))
    s = sum(arr)
    if s == 0:
        print( 1 + max((n-1-k)//k,0) )
    else:
        t = 0
        wHave = 0
        dist = []
        for i in range(0,n):
            if not arr[i]:
                wHave+=1
            elif wHave:
                dist.append(wHave)
                wHave = 0
        dist.append(wHave)

        for i in range(1,len(dist)-1):
            t+= max((dist[i]-k)//(k+1),0)
        t+=max((dist[0])//(k+1),0)
        if (len(dist) > 1):
            t += max((dist[len(dist)-1]) // (k + 1), 0)
        print(t)


for _ in range(int(input())):
    n, k = list(map(int,input().split()))
    arr = list(input())
    arr = list(map(int,arr))
    s = sum(arr)
    if s == 0:
        print((n+(k-1)) + (n-(((n+(k-1)))* (k+1) - k))//(k+1) )
    else:
        t = 0
        wHave = 0
        dist = []
        for i in range(n):
            if not arr[i]:
                wHave+=1
            elif wHave:
                dist.append(wHave)
                wHave = 0
        if wHave:
            dist.append(wHave)
        # print(dist)
        # print((arr[0]+1)&1,len(dist)-((arr[n-1]+1)&1))
        for i in range((arr[0]+1)&1,len(dist)-(arr[n-1]+1)&1):
            t+= max((dist[i]-k)//(k+1),0)
        if not arr[0]:
            t+=max((dist[0])//(k+1),0)
        if not arr[n-1]:
            if (len(dist) > 1):
                t += max((dist[len(dist)-1]) // (k + 1), 0)
        print(t)


for _ in range(int(input())):
    n, k = list(map(int,input().split()))
    arr = list(input())
    arr = list(map(int,arr))
    s = sum(arr)
    if s == 0:
        print((n+(k-1)) + (n-(((n+(k-1)))* (k+1) - k))//(k+1) )
    else:
        t = 0
        wHave = 0
        dist = []
        for i in range(0,n):
            if not arr[i]:
                wHave+=1
            elif wHave:
                dist.append(wHave)
                wHave = 0
        dist.append(wHave)

        for i in range(1,len(dist)-1):
            t+= max((dist[i]-k)//(k+1),0)
        t+=max((dist[0])//(k+1),0)
        if (len(dist) > 1):
            t += max((dist[len(dist)-1]) // (k + 1), 0)
        print(t)


for _ in range(int(input())):
    n, k = list(map(int,input().split()))
    arr = list(input())
    arr = list(map(int,arr))
    s = sum(arr)
    if s == 0:
        print((n+(k-1)) + (n-(((n+(k-1)))* (k+1) - k))//(k+1) )
    else:
        t = 0
        wHave = 0
        dist = []
        for i in range(n):
            if not arr[i]:
                wHave+=1
            elif wHave:
                dist.append(wHave)
                wHave = 0
        if wHave:
            dist.append(wHave)
        # print(dist)
        # print((arr[0]+1)&1,len(dist)-((arr[n-1]+1)&1))
        for i in range((arr[0]+1)&1,len(dist)-((arr[n-1]+1)&1)):
            t+= max((dist[i]-k)//(k+1),0)
        if not arr[0]:
            t+=max((dist[0])//(k+1),0)
        if not arr[n-1]:
            t += max((dist[len(dist)-1]) // (k + 1), 0)
        print(t)


for _ in range(int(input())):
    n, k = list(map(int,input().split()))
    arr = list(input())
    arr = list(map(int,arr))
    s = sum(arr)
    if s == 0:
        print((n+(k-1)) + (n-(((n+(k-1)))* (k+1) - k))//(k+1) )
    else:
        t = 0
        wHave = 0
        dist = []
        for i in range(n):
            if not arr[i]:
                wHave+=1
            elif wHave:
                dist.append(wHave)
                wHave = 0
        if wHave:
            dist.append(wHave)
        # print(dist)
        # print((arr[0]+1)&1,len(dist)-((arr[n-1]+1)&1))
        for i in range((arr[0]+1)&1,len(dist)-((arr[n-1]+1)&1)):
            t+= max((dist[i]-k)//(k+1),0)
        if not arr[0]:
            t+=max((dist[0])//(k+1),0)
        if not arr[n-1]:
            if (len(dist) > 1):
                t += max((dist[len(dist)-1]) // (k + 1), 0)
        print(t)


t = int(input())
while t:
    a = input()
    s = input()
    n,k = [int(x) for x in a.split()]
    a=0
    w = 0
    if s[0]!=1:
        try:
            d = s.index('1')
            q = s[:d]
            s = s[d:]
        except ValueError:
            q = s
            if len(q)>k+1:
                w = (len(q))/(k+1)
                if w%k !=0:
                    a = int(w) + 1
                else: a=w
                print(w)
            else: print(1)
            break

        w = (len(q)-k)/(k+1)
        if w>=0:
            if w%k !=0:
                a = int(w) + 1
            else: a=w
    if s[-1]!=1:
        d = s.rindex('1')
        q = s[d+1:]
        s = s[:d+1]
        w = (len(q)-k)/(k+1)
        if w>=0 and q:
            if w%k !=0:
                a += int(w) + 1
            else: a+=w

    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w%k !=0:
            a += int(w) + 1
        else: a+=w
    print(int(a))
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    z = True
    n,k = [int(x) for x in a.split()]
    s = [x for x in s.split('1')]
    s = [x for x in s if x]
    a=0
    q = 0
    try:
        d = s.index('1')
        q = s[:d]
        s = s[d:]
        w = (len(q)-k)/(k+1)
    except ValueError:
        z = False
    if w>=0 and q:
        if w%k !=0:
            a = int(w) + 1
        else: a=w
    if z:
        d = s.rindex('1')
        q = s[d+1:]
        s = s[:d+1]
        w = (len(q)-k)/(k+1)
    if w>=0 and q:
        if w%k !=0:
            a += int(w) + 1
        else: a+=w
    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w%k !=0:
            a += int(w) + 1
        else: a+=w
    print(int(a))
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    n,k = [int(x) for x in a.split()]
    s = s.split('1')
    a=0
    for i in s:
        if len(i)>(k*2):
            a += (len(i)-(k*2))
    print(a)
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    n,k = [int(x) for x in a.split()]
    a=0
    w = 0
    if s[0]!=1:
        try:
            d = s.index('1')
            q = s[:d]
            s = s[d:]
        except ValueError:
            q = s
            if len(q)>k+1:
                w = (len(q))/(k+1)
                if w%k !=0:
                    a = int(w) + 1
                else: a=w
                print(int(w))
            else: print(1)
            break

        w = (len(q)-k)/(k+1)
        if w>=0:
            if w%k !=0:
                a = int(w) + 1
            else: a=w
    if s[-1]!=1:
        d = s.rindex('1')
        q = s[d+1:]
        s = s[:d+1]
        w = (len(q)-k)/(k+1)
        if w>=0 and q:
            if w%k !=0:
                a += int(w) + 1
            else: a+=w

    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w%k !=0:
            a += int(w) + 1
        else: a+=w
    print(int(a))
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    n,k = [int(x) for x in a.split()]
    a=0
    w = 0
    if s[0]!=1:
        try:
            d = s.index('1')
            q = s[:d]
            s = s[d:]
        except ValueError:
            q = s
            if len(q)>k+1:
                w = (len(q))/(k+1)
                if w%k !=0:
                    a = int(w) + 1
                else:
                    a=w
                print(int(a))
            else:
                print(1)
            t-=1
            continue

        w = (len(q)-k)/(k+1)
        if w>=0:
            if w%k !=0:
                a = int(w) + 1
            else: a=w
    if s[-1]!=1:
        d = s.rindex('1')
        q = s[d+1:]
        s = s[:d+1]
        w = (len(q)-k)/(k+1)
        if w>=0 and q:
            if w%k !=0:
                a += int(w) + 1
            else: a+=w

    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w>=0:
            if w%k !=0:
                a += int(w) + 1
            else: a+=w
    print(int(a))
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    z = True
    n,k = [int(x) for x in a.split()]
    s = [x for x in s.split('1')]
    s = [x for x in s if x]
    a=0
    q = 0
    try:
        d = s.index('1')
        q = s[:d]
        s = s[d:]
    except ValueError:
        z = False
    w = (len(q)-k)/(k+1)
    if w>=0:
        if w%k !=0:
            a = int(w) + 1
        else: a=w
    if z:
        d = s.rindex('1')
        q = s[d+1:]
        s = s[:d+1]
    w = (len(q)-k)/(k+1)
    if w>=0:
        if w%k !=0:
            a += int(w) + 1
        else: a+=w
    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w%k !=0:
            a += int(w) + 1
        else: a+=w
    print(int(a))
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    z = True
    n,k = [int(x) for x in a.split()]
    a=0
    q = 0
    w = -1
    try:
        d = s.index('1')
        q = s[:d]
        s = s[d:]
        w = (len(q)-k)/(k+1)
    except ValueError:
        z = False
    if w>=0 and q:
        if w%k !=0:
            a = int(w) + 1
        else: a=w
    if z:
        d = s.rindex('1')
        q = s[d+1:]
        s = s[:d+1]
        w = (len(q)-k)/(k+1)
    if w>=0 and q:
        if w%k !=0:
            a += int(w) + 1
        else: a+=w
    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w%k !=0:
            a += int(w) + 1
        else: a+=w
    print(int(a))
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    n,k = [int(x) for x in a.split()]
    a=0
    w = 0
    if s[0]!=1:
        try:
            d = s.index('1')
            q = s[:d]
            s = s[d:]
        except ValueError:
            q = s
            if len(q)>k+1:
                w = (len(q))/(k+1)
                if w%k !=0:
                    a = int(w) + 1
                else: a=w
                print(int(w))
            else: print(1)
            break

        w = (len(q)-k)/(k+1)
        if w>=0:
            if w%k !=0:
                a = int(w) + 1
            else: a=w
    if s[-1]!=1:
        d = s.rindex('1')
        q = s[d+1:]
        s = s[:d+1]
        w = (len(q)-k)/(k+1)
        if w>=0 and q:
            if w%k !=0:
                a += int(w) + 1
            else: a+=w

    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w>=0:
            if w%k !=0:
                a += int(w) + 1
            else: a+=w
    print(int(a))
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    z = True
    n,k = [int(x) for x in a.split()]
    a=0
    q = 0
    w = -1
    if s[0]!=1:
        try:
            d = s.index('1')
            q = s[:d]
            s = s[d:]
            w = (len(q)-k)/(k+1)
        except ValueError:
            z = False
        if w>=0 and q:
            if w%k !=0:
                a = int(w) + 1
            else: a=w
    if s[-1]!=1:
        if z:
            d = s.rindex('1')
            q = s[d+1:]
            s = s[:d+1]
            w = (len(q)-k)/(k+1)
        if w>=0 and q:
            if w%k !=0:
                a += int(w) + 1
            else: a+=w

    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w%k !=0:
            a += int(w) + 1
        else: a+=w
    print(int(a))
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    n,k = [int(x) for x in a.split()]
    a=0

    w = 0
    if s[0]!=1:
        try:
            d = s.index('1')
            q = s[:d]
            s = s[d:]
        except ValueError:
            q = s
            if len(q)>k+1:
                w = (len(q))/(k+1)
                if w%1 !=0:
                    a = int(w) + 1
                else:
                    a=w
                print(int(a))
            else:
                print(1)
            t-=1
            continue

        w = (len(q)-k)/(k+1)
        if w>=0:
            if w%1 !=0:
                a = int(w) + 1
            else: a=w
    if s[-1]!=1:
        d = s.rindex('1')
        q = s[d+1:]
        s = s[:d+1]
        w = (len(q)-k)/(k+1)
        if w>=0:
            if w%1 !=0:
                a = (int(w)) + 1 + a
            else:
                a+=w
    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w>=0:
            if w%1 !=0:
                a += int(w) + 1
            else: a+=w
    print(int(a))
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    n,k = [int(x) for x in a.split()]
    a=0
    w = 0
    if s[0]!=1:
        try:
            d = s.index('1')
            q = s[:d]
            s = s[d:]
        except ValueError:
            q = s
            if len(q)>k+1:
                w = (len(q))/(k+1)
                if w%k !=0:
                    a = int(w) + 1
                else: a=w
                print(int(w))
            else: print(1)
            t-=1
            continue

        w = (len(q)-k)/(k+1)
        if w>=0:
            if w%k !=0:
                a = int(w) + 1
            else: a=w
    if s[-1]!=1:
        d = s.rindex('1')
        q = s[d+1:]
        s = s[:d+1]
        w = (len(q)-k)/(k+1)
        if w>=0 and q:
            if w%k !=0:
                a += int(w) + 1
            else: a+=w

    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w>=0:
            if w%k !=0:
                a += int(w) + 1
            else: a+=w
    print(int(a))
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    n,k = [int(x) for x in a.split()]
    s = s.split('1')
    a=0
    if len(s) == 1:
        a = 1
    else:
        x,y = s[0],s[-1]
        if len(x)>k:
            a+=len(x)-k
        if len(y)>k:
            a+=len(y)-k
        for i in s:
            if len(i)>(k*2):
                a += (len(i)-(k*2))
    print(a)
    t-=1


t = int(input())
while t:
    a = input()
    s = input()
    z = True
    n,k = [int(x) for x in a.split()]
    #s = [x for x in s.split('1')]
    #s = [x for x in s if x]
    a=0
    q = 0
    try:
        d = s.index('1')
        q = s[:d]
        s = s[d:]
    except ValueError:
        z = False
    w = (len(q)-k)/(k+1)
    if w%k !=0:
        a = int(w) + 1
    else: a=w
    if z:
        d = s.rindex('1')
        q = s[d+1:]
        s = s[:d+1]
    w = (len(q)-k)/(k+1)
    if w%k !=0:
        a += int(w) + 1
    else: a+=w
    s = [x for x in s.split('1')]
    s = [x for x in s if x]

    for i in s:
        w = ((len(i)-(2*k)))/(k+1)
        if w%k !=0:
            a += int(w) + 1
        else: a+=w
    print(int(a))
    t-=1


testcases = int(input())
for i in range(testcases):
    n, k = map(int,  input().strip().split(" "))
    l = list(map(int, input()))
    count = 0
    if k >= len(l):
        if sum(l) == 0:
            print(1)
        else:
            print(0)
    else:
        if sum(l[0: k + 1]) == 0:
            l[0] = 1
            count += 1

        if sum(l[len(l) - (k + 1): len(l)]) == 0:
            l[-1] = 1
            count += 1

        j = 0
        while j + k < len(l):
            x = sum(l[j: 2 * k + j + 1])
            if x == 0:
                l[int((2 * k + 1 + j) / 2)] = 1
                count += 1
            j += 1
        print(count)


testcases = int(input())
for i in range(testcases):
    n, k = map(int,  input().strip().split(" "))
    l = list(map(int, input()))
    count = 0
    if k >= len(l):
        if sum(l) == 0:
            print(1)
        else:
            print(0)
    else:
        if sum(l[0: k + 1]) == 0:
            l[0] = 1
            count += 1

        if sum(l[len(l) - (k + 1): len(l)]) == 0:
            l[-1] = 1
            count += 1

        j = 0
        while j + 2*k < len(l):
            x = sum(l[j: 2 * k + j + 1])
            if x == 0:
                l[int((2 * k + 1 + j + j) / 2)] = 1
                j = int((2 * k + 1 + j + j) / 2)
                count += 1
            j += 1
        print(count)


testcases = int(input())
for i in range(testcases):
    n, k = map(int,  input().strip().split(" "))
    l = list(map(int, input()))
    count = 0
    if k >= len(l):
        print(1)
    else:
        if sum(l[0: k + 1]) == 0:
            l[0] = 1
            count += 1

        if sum(l[len(l) - (k + 1): len(l)]) == 0:
            l[-1] = 1
            count += 1

        j = 0
        while j + k < len(l):
            x = sum(l[j: 2 * k + j + 1])
            if x == 0:
                l[int((2 * k + 1 + j) / 2)] = 1
                count += 1
            j += 1
        print(count)


testcases = int(input())
for i in range(testcases):
    n, k = map(int,  input().strip().split(" "))
    l = list(map(int, input()))
    count = 0
    if k >= len(l):
        if sum(l) == 0:
            print(1)
        else:
            print(0)
    else:
        if sum(l[0: k + 1]) == 0:
            l[0] = 1
            count += 1

        if sum(l[len(l) - (k + 1): len(l)]) == 0:
            l[-1] = 1
            count += 1

        j = 0
        while j + 2*k < len(l):
            x = sum(l[j: 2 * k + j + 1])
            if x == 0:
                l[int((2 * k + 1 + j) / 2)] = 1
                count += 1
            j += 1
        print(count)


testcases = int(input())
for i in range(testcases):
    n, k = map(int,  input().strip().split(" "))
    l = list(map(int, input()))
    i = 0
    count = 0
    if sum(l[0: k + 1]) == 0:
        count += 1
        l[0] = 1
        i += 1

    while i < len(l):
        if 2 * k + i + 1 <= len(l):
            x = sum(l[i: 2 * k + i + 1])
            if x == 0:
                count += 1
                i += 2 * k
            else:
                i += 1
        else:
            i += 1

    print(count)


testcases = int(input())
for i in range(testcases):
    n, k = map(int,  input().strip().split(" "))
    l = list(map(int, input()))
    count = 0
    if k >= len(l):
        if sum(l) == 0:
            print(1)
        else:
            print(0)
    else:
        if sum(l[0: k + 1]) == 0:
            l[0] = 1
            count += 1

        if sum(l[len(l) - (k + 1): len(l)]) == 0:
            l[-1] = 1
            count += 1

        j = 0
        while j + 2*k < len(l):
            x = sum(l[j: 2 * k + j + 1])
            if x == 0:
                l[int((2 * k + 1 + j) / 2)] = 1
                count += 1
            j += 1
        print(count)
        print(l)


for _ in range(int(input())):
    n, k = map(int, input().split())
    k += 1
    s = input()

    l = -k

    c = 0

    for i, j in enumerate(s):
        if j == '1':
            d = i - l
            c += (d-1) // k

            l = i

    d = n - l
    c += (d-1) // k

    print(c)


for _ in range(int(input())):
    n, k = map(int, input().split())
    s = input()
    n = len(s)

    if '1' not in s:
        print((n-1) // (k+1) + 1)
        continue

    l = -1
    c = 0

    for i, j in enumerate(s):
        if j == '1':
            if l == -1:
                c += i // (k+1)
            else:
                d = i-l-1
                c += max(0, (d - k * 2 - 1) // (k+1) + 1)

            l = i

    c += (n-l-1) // (k+1)

    print(c)


for _ in range(int(input())):
    n, k = map(int, input().split())
    s = input()
    n = len(s)

    if '1' not in s:
        print((n-1) // (k+1) + 1)
        continue

    s += '1'

    l = -1
    c = 0

    for i, j in enumerate(s):
        if j == '1':
            if l == -1:
                c += i // (k+1)
            else:
                d = i-l-1
                c += max(0, (d - k * 2 - 1) // (k+1) + 1)

            l = i

    print(c)


for _ in range(int(input())):
    n, k = map(int, input().split())
    s = input()

    if n <= k:
        if '1' in s:
            print(0)
        else:
            print(1)

        continue

    s += '1'

    l = -1
    c = 0

    for i, j in enumerate(s):
        if j == '1':
            c += max(0, (i - l - 1) // (k+1))
            l = i

    print(c)


for _ in range(int(input())):
    n, k = map(int, input().split())
    s = input()
    n = len(s)

    if '1' not in s:
        print((n-1) // (k+1) + 1)
        continue

    s += '1'

    l = -1
    c = 0

    for i, j in enumerate(s):
        if j == '1':
            if l == -1:
                c += max(0, i // (k + 1))

            else:
                c += max(0, (i - l - 1 - k) // (k+1))

            l = i

    print(c)


for _ in range(int(input())):
    n,k=map(int,input().split())
    s=list(input())

    if s.count('1')==0:
        print(1+(n-1)//(k+1))

    else:
        ans=0
        ind=[]
        for i in range(n):
            if s[i]=='1':
                ind.append(i)

        #print(ind)

        if ind[0]>k:
            ans=1+(ind[0]-1)//(k+1)

        for i in range(len(ind)-1):
            if ind[i+1]>ind[i]+2*k:
                ans+=1

        if n-ind[-1]>k+1:
            ans+=(n-ind[-1]-1)//(k+1)

        print(ans)


for _ in range(int(input())):
    n,k=map(int,input().split())
    s=list(input())

    if s.count('1')==0:
        print(1+(n-1)//(k+1))

    else:
        ans=0
        ind=[]
        for i in range(n):
            if s[i]=='1':
                ind.append(i)

        if ind[0]>k:
            ans=1+(ind[0]-1)//(k+1)

        if n-ind[-1]>k+1:
            ans+=(n-ind[-1]-1)//(k+1)

        for i in range(len(ind)-1):
            if ind[i+1]-ind[i]>2*k+1:
                ans+=1

        print(ans)


for _ in range(int(input())):
    n,k=map(int,input().split())
    s=list(input())

    ans=0
    i=0
    x=0

    while(i<n):
        for j in range(i,i+k+1):
            if j<n and s[j]=='1':
                x+=1
                break

            elif j>=n:
                break

        i+=(k+1)

        if x==0:
            ans+=1
        else:
            x-=1

    print(ans)


for _ in range(int(input())):
    n,k=map(int,input().split())
    s=list(input())

    if len(s)==1 and s==['0']:
        print(1)
    elif len(s)==1 and s==['1']:
        print(0)

    elif s.count('1')==0:
        print(1+(n-2)//(k+1))

    else:
        ans=0
        ind=[]
        for i in range(n):
            if s[i]=='1':
                ind.append(i)

        if ind[0]>k:
            ans=1+(ind[0]-2)//(k+1)

        if n-ind[-1]>k+1:
            ans+=(n-ind[-1]-1)//(k+1)

        for i in range(len(ind)-1):
            if ind[i+1]-ind[i]>2*k+1:
                ans+=1

        print(ans)


for _ in range(int(input())):
    n,k=map(int,input().split())
    s=list(input())

    if s.count('1')==0:
        print(1+(n-1)//(k+1))

    else:
        ans=0
        ind=[]
        for i in range(n):
            if s[i]=='1':
                ind.append(i)

        if ind[0]>k:
            ans=1+(ind[0]-2)//(k+1)

        if n-ind[-1]>k+1:
            ans+=(n-ind[-1]-1)//(k+1)

        for i in range(len(ind)-1):
            if ind[i+1]-ind[i]>2*k+1:
                ans+=1

        print(ans)


for _ in range(int(input())):
    n,k=map(int,input().split())
    s=list(input())

    if s.count('1')==0:
        print(1+(n-2)//(k+1))

    else:
        ans=0
        ind=[]
        for i in range(n):
            if s[i]=='1':
                ind.append(i)

        if ind[0]>k:
            ans=1+(ind[0]-2)//(k+1)

        if n-ind[-1]>k+1:
            ans+=(n-ind[-1]-1)//(k+1)

        for i in range(len(ind)-1):
            if ind[i+1]-ind[i]>2*k+1:
                ans+=1

        print(ans)


for _ in range(int(input())):
    n,k=map(int,input().split())
    s=list(input())

    if s.count('1')==0:
        print(1+(n-1)//(k+1))

    else:
        ans=0
        ind=[]
        for i in range(n):
            if s[i]=='1':
                ind.append(i)

        if ind[0]>k:
            ans=1+(ind[0]-1)//(k+1)

        if n-ind[-1]>k:
            ans+=(n-ind[-1]-1)//(k+1)

        for i in range(len(ind)-1):
            if ind[i+1]-ind[i]>2*k+1:
                ans+=1

        print(ans)


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#define ll long long
using namespace std;

int main(){
    int t;
    int n, m, x, y;
    cin >> t;
    while(t--){
        int price = 0;
        bool prev = false;
        char mapp[110][1010];
        cin >> n >> m >> x >> y;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                cin >> mapp[i][j];
            }
        }
        for (int i = 0; i < n; i++){//every row, clear prev flag
            for (int j = 0; j < m; j++){ //looping through

                if (mapp[i][j] == '.' && j + 1 < m && mapp[i][j+1] == '.'){
                    price += min(2*x, y);
                    j+=1;
                }
                else if (mapp[i][j] == '.'){
                    price += x;
                }
            }
        }
        cout << price << endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#define ll long long
using namespace std;

int main(){
    int t;
    int n, m, x, y;
    cin >> t;
    while(t--){
        int price = 0;
        bool prev = false;
        char mapp[400][400];
        cin >> n >> m >> x >> y;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                cin >> mapp[i][j];
            }
        }
        for (int i = 0; i < n; i++){
            prev = false;
            for (int j = 0; j < m; j++){ //looping through

                if (mapp[i][j] == '.'){ // if white tile

                    if (prev == true){ // looking for 2nd half
                        if (2*x < y) price += x;
                        else price = price - x + y;
                        prev = false;
                    }else{ // first white found
                        prev = true;
                        price += x;
                    }

                }else{//not white, reset prev flag
                    prev = false;
                }
            }
        }
        cout << price << endl;
    }

    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#define ll long long
using namespace std;

int main(){
    int t;
    int n, m, x, y;
    cin >> t;
    while(t--){
        ll price = 0;
        bool prev = false;
        char mapp[400][4010];
        cin >> n >> m >> x >> y;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                cin >> mapp[i][j];
            }
        }
        for (int i = 0; i < n; i++){//every row,
            prev = false;
            for (int j = 0; j < m; j++){ //looping through

                if (mapp[i][j] == '.'){ // if white tile

                    if (prev == true){ // looking for 2nd half
                        if (2*x < y) price += x;
                        else price = price - x + y;
                        prev = false;
                    }else{ // first white found
                        prev = true;
                        price += x;
                    }

                }else{//not white, reset prev flag
                    prev = false;
                }
            }
        }
        cout << price << endl;
    }

    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#define ll long long
using namespace std;

int main(){
    int t;
    int n, m, x, y;
    cin >> t;
    while(t--){
        int price = 0;
        bool prev = false;
        char mapp[400][400];
        cin >> n >> m >> x >> y;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                cin >> mapp[i][j];
            }
        }
        for (int i = 0; i < n; i++){//every row, clear prev flag
            for (int j = 0; j < m; j++){ //looping through

                if (mapp[i][j] == '.' && j + 1 < m && mapp[i][j+1] == '.'){
                    price += min(2*x, y);
                    j+=1;
                }
                else if (mapp[i][j] == '.'){
                    price += x;
                }
            }
        }
        cout << price << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,x,y;
    cin>>m>>n>>x>>y;
    char t[m][n];
    for(int i=0; i<m; i++)
        for(int ii=0; ii<n; ii++)
            cin>>t[i][ii];
    int cost=0;
    if(n==1 || x<y){
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }

    else{
        for(int i=0; i<m; i++){
            int l=0;
            for(int j=1; j<n; j++){
                if(t[i][j]=='.' &&t[i][l]){
                    cost+=y;
                    j+=2;
                    l+=2;
                }
                else if(t[i][j] =='.' || t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }
    cout<<cost<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--){
    int m,n,x,y;
    cin>>m>>n>>x>>y;
    char t[m][n];
    for(int i=0; i<m; i++)
        for(int ii=0; ii<n; ii++)
            cin>>t[i][ii];
    int cost=0;
    if(n==1 || x<y){
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }

    else{
        for(int i=0; i<m; i++){
            int l=1;
            for(int j=0; j<n-1; j++){
                if(t[i][j]=='.' &&t[i][j+1]=='.'){
                    cost+=y;
                    j+=2;
                }
                else if(t[i][j] =='.' || t[i][j+1]=='.'){
                    cost+=x;
                }
            }
        }
    }
    cout<<cost<<endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--){
    int m,n,x,y;
    cin>>m>>n>>x>>y;
    char t[m][n];
    for(int i=0; i<m; i++)
        for(int ii=0; ii<n; ii++)
            cin>>t[i][ii];
    int cost=0;
    if(n==1 || x*2<=y){
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }

    else{
        for(int i=0; i<m; i++){

            for(int j=0; j<n-1; j++){
                if(t[i][j]=='.' &&t[i][j+1]=='.'){
                    cost+=y;
                    j+=1;
                }
                else if(t[i][j] =='.' || t[i][j+1]=='.'){
                    cost+=x;
                }
            }
        }
    }
  //  int mxo = cost;
    cout<<cost<<endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--){
    int m,n,x,y;
    cin>>m>>n>>x>>y;
    char t[m][n];
    for(int i=0; i<m; i++)
        for(int ii=0; ii<n; ii++)
            cin>>t[i][ii];
    int cost=0;
    if(n==1 || x<y){
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }

    else{
        for(int i=0; i<m; i++){
            int l=0;
            for(int j=1; j<n; j++){
                if(t[i][j]=='.' &&t[i][l]){
                    cost+=y;
                    j+=2;
                    l+=2;
                }
                else if(t[i][j] =='.' || t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }
    cout<<cost<<endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--){
    int m,n,x,y;
    cin>>m>>n>>x>>y;
    char t[m][n+1];

    for(int i=0; i<m; i++)
        for(int ii=0; ii<n; ii++)
            cin>>t[i][ii];
    for(int i=0; i<m; i++)t[i][n]='*';
    int cost=0;
    if(n==1 || x*2<=y){
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }

    else{
        for(int i=0; i<m; i++){

            for(int j=0; j<n; j++){

                if(t[i][j]=='.'){
                    if(t[i][j+1]=='.'){
                        cost+=y;
                        j++;
                    }
                    else{
                        cost+=x;
                    }
                }
            }
        }
    }
  //  int mxo = cost;
    cout<<cost<<endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--){
    int m,n,x,y;
    cin>>m>>n>>x>>y;
    char t[m][n];
    for(int i=0; i<m; i++)
        for(int ii=0; ii<n; ii++)
            cin>>t[i][ii];
    int cost=0;
    if(n==1 || x*2<y){
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }

    else{
        for(int i=0; i<m; i++){

            for(int j=0; j<n-1; j++){
                if(t[i][j]=='.' &&t[i][j+1]=='.'){
                    cost+=y;
                    j+=1;
                }
                else if(t[i][j] =='.' || t[i][j+1]=='.'){
                    cost+=x;
                }
            }
        }
    }
    cout<<cost<<endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--){
    int m,n,x,y;
    cin>>m>>n>>x>>y;
    char t[m][n];
    for(int i=0; i<m; i++)
        for(int ii=0; ii<n; ii++)
            cin>>t[i][ii];
    int cost=0;
    if(n==1 || x*2<y){
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }

    else{
        for(int i=0; i<m; i++){

            for(int j=0; j<n-1; j++){
                if(t[i][j]=='.' &&t[i][j+1]=='.'){
                    cost+=y;
                    j+=1;
                }
                else if(t[i][j] =='.' || t[i][j+1]=='.'){
                    cost+=x;
                }
            }
        }
    }
    int mxo = cost;
    cout<<mxo<<endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--){
    int m,n,x,y;
    cin>>m>>n>>x>>y;
    char t[m][n];
    for(int i=0; i<m; i++)
        for(int ii=0; ii<n; ii++)
            cin>>t[i][ii];
    int cost=0;
    if(n==1 || x<y){
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }

    else{
        for(int i=0; i<m; i++){

            for(int j=0; j<n-1; j++){
                if(t[i][j]=='.' &&t[i][j+1]=='.'){
                    cost+=y;
                    j+=1;
                }
                else if(t[i][j] =='.' || t[i][j+1]=='.'){
                    cost+=x;
                }
            }
        }
    }
    cout<<cost<<endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--){
    int m,n,x,y;
    cin>>m>>n>>x>>y;
    char t[m][n];
    for(int i=0; i<m; i++)
        for(int ii=0; ii<n; ii++)
            cin>>t[i][ii];
    int cost=0;
    if(n==1 || x<y){
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(t[i][j]=='.'){
                    cost+=x;
                }
            }
        }
    }

    else{
        for(int i=0; i<m; i++){
            int l=1;
            for(int j=0; j<n; j++){
                if(t[i][j]=='.' &&t[i][l]=='.'){
                    cost+=y;
                    j+=2;
                    l+=2;
                }
                else if(t[i][j] =='.' || t[i][j+1]=='.'){
                    cost+=x;
                }
            }
        }
    }
    cout<<cost<<endl;
}
}


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

int main() {
    int t;
    cin>>t;
    while(t--) {
        long long n, m, x, y;
        cin>>n>>m>>x>>y;
        char arr[n][m];
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++)
                cin>>arr[i][j];
        }
        long long count_dots = 0;
        long long cons_count = 0;
        long long cost = 0;
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
                if(arr[i][j] == '.')
                    count_dots++;
            }
        }
        if(m==1)
                cost = count_dots*x;
        else {
            for(int i=0; i<n; i++) {
                for(int j=0; j<m-1; j++) {
                    if(arr[i][j] == '.' && arr[i][j+1] == '.') {
                        cost += y;
                        cons_count++;
                        j++;
                    }
                    else if(arr[i][j]=='.')
                        cost += x;
                }
            }
        }
        cost = min(cost, count_dots*x);
        cout<<cost<<endl;
    }
    return 0;
}


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

int main() {
    int t;
    cin>>t;
    while(t--) {
        int n, m, x, y;
        cin>>n>>m>>x>>y;
        char arr[n][m];
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++)
                cin>>arr[i][j];
        }
        int count_dots = 0;
        int cost = 0;
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
                if(arr[i][j] == '.')
                    count_dots++;
            }
        }
        for(int i=0; i<n; i++) {
            if(m==1)
                cost = count_dots*x;
            else {
                for(int j=0; j<m-1; j++) {
                    if(arr[i][j] == '.' && arr[i][j+1] == '.') {
                        cost += y;
                        j++;
                    }
                    else if(arr[i][j]=='.')
                        cost += x;
                }
                if(arr[i][m-1]=='.' && arr[i][m-2]!='.')
                    cost+=x;
            }

        }
        cost = min(cost, count_dots*x);
        cout<<cost<<endl;
    }

    return 0;
}


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

int main() {
    int t;
    cin>>t;
    while(t--) {
        long long n, m, x, y;
        cin>>n>>m>>x>>y;
        char arr[n][m];
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++)
                cin>>arr[i][j];
        }
        long long count_dots = 0;
        long long cost = 0;
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
                if(arr[i][j] == '.')
                    count_dots++;
            }
        }
        if(m==1)
                cost = count_dots*x;
        else{
            for(int i=0; i<n; i++) {
                for(int j=0; j<m-1; j++) {
                    if(arr[i][j] == '.' && arr[i][j+1] == '.') {
                        cost += y;
                        j++;
                    }
                    else if(arr[i][j]=='.')
                        cost += x;
                    else if(arr[i][j+1]=='.')
                        cost += x;
                }
            }
        }
        cost = min(cost, count_dots*x);
        cout<<cost<<endl;
    }
    return 0;
}


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

int main() {
    int t;
    cin>>t;
    while(t--) {
        long long n, m, x, y;
        cin>>n>>m>>x>>y;
        char arr[n][m];
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++)
                cin>>arr[i][j];
        }
        long long count_dots = 0;
        long long cons_count = 0;
        long long cost = 0;
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
                if(arr[i][j] == '.')
                    count_dots++;
            }
        }
        for(int i=0; i<n; i++) {
            if(m==1)
                cost = count_dots*x;
            else {
                for(int j=0; j<m-1; j++) {
                    if(arr[i][j] == '.' && arr[i][j+1] == '.') {
                        cost += y;
                        cons_count++;
                        j++;
                    }
                    else if(arr[i][j]=='.')
                        cost += x;
                    j++;
                }
                // if(arr[i][m-1]=='.' && arr[i][m-2]!='.') {
                //     cost+=x;
                // }
            }
        }
        cost = min((count_dots-cons_count*2)*y + count_dots*x, count_dots*x);
        cout<<cost<<endl;
    }
    return 0;
}


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

int main() {
    int t;
    cin>>t;
    while(t--) {
        long long n, m, x, y;
        cin>>n>>m>>x>>y;
        char arr[n][m];
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++)
                cin>>arr[i][j];
        }
        long long count_dots = 0;
        long long cons_count = 0;
        long long cost = 0;
        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
                if(arr[i][j] == '.')
                    count_dots++;
            }
        }
        for(int i=0; i<n; i++) {
            if(m==1)
                cost = count_dots*x;
            else {
                for(int j=0; j<m-1; j++) {
                    if(arr[i][j] == '.' && arr[i][j+1] == '.') {
                        cost += y;
                        cons_count++;
                        j++;
                    }
                    else if(arr[i][j]=='.')
                        cost += x;
                    j++;
                }
                if(arr[i][m-1]=='.' && arr[i][m-2]!='.') {
                    cost+=x;
                }
            }
        }
        cost = min((count_dots*2-cons_count)*y + count_dots*x, count_dots*x);
        cout<<cost<<endl;
    }
    return 0;
}