Polycarp and his friends want to visit a new restaurant. The restaurant has $n$ tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from $1$ to $n$ in the order from left to right. The state of the restaurant is described by a string of length $n$ which contains characters "1" (the table is occupied) and "0" (the table is empty).

Restaurant rules prohibit people to sit at a distance of $k$ or less from each other. That is, if a person sits at the table number $i$, then all tables with numbers from $i-k$ to $i+k$ (except for the $i$-th) should be free. In other words, the absolute difference of the numbers of any two occupied tables must be strictly greater than $k$.

For example, if $n=8$ and $k=2$, then:  strings "10010001", "10000010", "00000000", "00100000" satisfy the rules of the restaurant;  strings "10100100", "10011001", "11111111" do not satisfy to the rules of the restaurant, since each of them has a pair of "1" with a distance less than or equal to $k=2$. 

In particular, if the state of the restaurant is described by a string without "1" or a string with one "1", then the requirement of the restaurant is satisfied.

You are given a binary string $s$ that describes the current state of the restaurant. It is guaranteed that the rules of the restaurant are satisfied for the string $s$.

Find the maximum number of free tables that you can occupy so as not to violate the rules of the restaurant. Formally, what is the maximum number of "0" that can be replaced by "1" such that the requirement will still be satisfied?

For example, if $n=6$, $k=1$, $s=$ "100010", then the answer to the problem will be $1$, since only the table at position $3$ can be occupied such that the rules are still satisfied.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases in the test. Then $t$ test cases follow.

Each test case starts with a line containing two integers $n$ and $k$ ($1 \le k \le n \le 2\cdot 10^5$) — the number of tables in the restaurant and the minimum allowed distance between two people.

The second line of each test case contains a binary string $s$ of length $n$ consisting of "0" and "1" — a description of the free and occupied tables in the restaurant. The given string satisfy to the rules of the restaurant — the difference between indices of any two "1" is more than $k$.

The sum of $n$ for all test cases in one test does not exceed $2\cdot 10^5$.


-----Output-----

For each test case output one integer — the number of tables that you can occupy so as not to violate the rules of the restaurant. If additional tables cannot be taken, then, obviously, you need to output $0$.


-----Example-----
Input
6
6 1
100010
6 2
000000
5 1
10101
3 1
001
2 2
00
1 1
0

Output
1
2
0
1
1
1



-----Note-----

The first test case is explained in the statement.

In the second test case, the answer is $2$, since you can choose the first and the sixth table.

In the third test case, you cannot take any free table without violating the rules of the restaurant.

Source: codeforces | Difficulty: EASY
Tags: Greedy algorithms

Mathematics

Constructive algorithms


Solutions:
from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().strip().split())
	s = input()
	arr = list(s)
	pre = []
	suf = []
	if arr[0] == '1':
		pre.append(0)
	else:
		pre.append(-1)
	for i in range(1, n):
		if arr[i] == '1':
			pre.append(i)
		else:
			pre.append(pre[-1])
	if arr[-1] == '1':
		suf.append(n - 1)
	else:
		suf.append(-1)
	for i in range(n - 2, -1, -1):
		if arr[i] == '1':
			suf.append(i)
		else:
			suf.append(suf[-1])
	suf = suf[::-1]
	ans = 0
	rec = -1
	for i in range(n):
		x = pre[i]
		y = suf[i]
		if x != -1 and y != -1:
			if abs(i - x) > k and abs(i - y) > k:
				if rec == -1:
					ans += 1
					rec = i
				elif abs(rec - i) > k:
					ans += 1
					rec = i
		elif x != -1 and y == -1:
			if abs(i - x) > k:
				if rec == -1:
					ans += 1
					rec = i
				elif abs(rec - i) > k:
					ans += 1
					rec = i
		elif x == -1 and y != -1:
			if abs(i - y) > k:
				if rec == -1:
					ans += 1
					rec = i
				elif abs(rec - i) > k:
					ans += 1
					rec = i
		elif rec == -1:
			ans += 1
			rec = i
		elif abs(rec - i) > k:
			ans += 1
			rec = i
	print(ans)


def read_int():
	return int(input())

def read_string_array():
	for s in input().split():
		yield s

def read_int_array():
	for s in read_string_array():
		yield int(s)

def read_line():
	return input()

def max_fill(n, k):
	cnt = 0
	while n > 0:
		cnt += 1
		n -= k + 1
	return cnt
from itertools import groupby

def solve(s, k):
	cnt = 0
	groups = groupby(s)
	groups = [(_, len(list(__))) for (_, __) in groups]
	for (i, (key, l)) in enumerate(groups):
		if key == '0':
			last_1 = i > 0
			next_1 = i != len(groups) - 1
		else:
			continue
		if last_1 and next_1:
			cnt += max_fill(l - 2 * k, k)
		elif last_1 or next_1:
			cnt += max_fill(l - k, k)
		else:
			cnt += max_fill(l, k)
	return cnt
T = read_int()
for _ in range(T):
	(N, K) = read_int_array()
	S = read_line()
	print(solve(S, K))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	L = [-1]
	for i in range(n):
		if s[i] == '1':
			L.append(i)
	L.append(n)
	cnt = 0
	m = len(L)
	S = [L[i + 1] - L[i] - 1 for i in range(m - 1)]
	m = len(S)
	for i in range(1, m - 1):
		cnt += (S[i] - k) // (k + 1)
	if m == 1:
		cnt += S[0] // (k + 1) + (S[0] % (k + 1) != 0)
	else:
		cnt += (S[0] - k) // (k + 1) + ((S[0] - k) % (k + 1) != 0)
	if m >= 2:
		cnt += (S[-1] - k) // (k + 1) + ((S[-1] - k) % (k + 1) != 0)
	print(cnt)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def diff(x, y):
	if x[1] - x[0] > y[1] - y[0]:
		return 1
	elif x[1] - x[0] == y[1] - y[0]:
		return x[0] < y[0]
	else:
		return 0

def tables(x, k):
	if x - k <= 0:
		return 0
	else:
		return (x - k) // (k + 1)

def main():
	t = inp()
	for l in range(t):
		(n, k) = invr()
		s = instr()
		(a, e) = (0, 0)
		if s[0] != '1':
			e += k
		for i in range(n):
			if s[i] == '0':
				e += 1
			elif s[i] == '1':
				a += tables(e, k)
				e = 0
		if s[n - 1] != '1':
			e += k
			a += tables(e, k)
		print(a)
main()


t = int(input())
for i in range(t):
	p = 0
	r = 0
	c = 0
	(n, k) = map(int, input().split())
	s = input()
	for i in range(n):
		if s[i] == '1':
			if p:
				r = r + max(0, (c + 1) // (k + 1) - 1)
			else:
				r = r + c // (k + 1)
			p = 1
			c = 0
		else:
			c = c + 1
	if p:
		r = r + c // (k + 1)
	else:
		r = 1 + (n - 1) // (k + 1)
	print(r)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	st = input()
	li = [-k - 1]
	for i in range(n):
		if st[i] == '1':
			li.append(i)
	li.append(n + k)
	ans = 0
	for i in range(1, len(li)):
		xx = li[i] - li[i - 1] - 1 - k
		ans += max(xx // (k + 1), 0)
	print(ans)


t = int(input())
for q in range(t):
	(n, k) = [int(f) for f in input().split()]
	s = input()
	k += 1
	ans = 0
	c = s.find('1')
	le = len(s)
	if c > -1:
		ans += c // k
		s = s[c + 1:len(s):1]
		c = s.find('1')
		while len(s) != 0 and c > -1:
			ans += (c - k + 1) // k
			s = s[c + 1:len(s):1]
			c = s.find('1')
		le = len(s)
		if le > 0:
			ans += le // k
	else:
		ans = (le - 1) // k + 1
	print(ans)


x = int(input())
for q in range(x):
	(n, m) = map(int, input().split())
	l = list(map(int, list(input())))
	for i in range(n):
		if l[i] == 1:
			for j in range(1, m + 1):
				if i + j < n:
					l[i + j] = 2
			for j in range(1, m + 1):
				if i - j >= 0:
					l[i - j] = 2
	c = 0
	ans = 0
	for i in range(n):
		if l[i] == 0:
			c += 1
		if l[i] != 0 or i == n - 1:
			ans += c // (m + 1)
			if c % (m + 1) != 0:
				ans += 1
			c = 0
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	binary = input()
	a = [1] * n
	ans = 0

	def change(i):
		a[i] = 0
		if i - k >= 0:
			for j in range(i, i - k - 1, -1):
				a[j] = 0
		else:
			for j in range(i, -1, -1):
				a[j] = 0
		if i + k < n:
			for j in range(i, i + k + 1, 1):
				a[j] = 0
		else:
			for j in range(i, n, 1):
				a[j] = 0
	for i in range(n):
		if binary[i] == '1':
			change(i)
	for i in range(n):
		if a[i] == 1:
			change(i)
			ans += 1
	print(ans)


def ai(s):
	l = []
	(a, b) = (0, 0)
	while 1:
		try:
			a = s.index('1', a)
			l.append(a)
			if a == len(s) - 1:
				return l
			a += 1
		except:
			return l
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if s[0] == '0':
		s = '1' + '0' * k + s
	if s[-1] == '0':
		s = s + '0' * k + '1'
	l = ai(s)
	ans = 0
	for i in range(len(l) - 1):
		x = l[i + 1] - l[i] - 1
		x -= k
		if x > 0:
			ans += x // (k + 1)
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	last1 = n - 1
	numbers = 1
	if n == 1 and s == '0':
		numbers = 1
	elif n == 1 and s == '1':
		numbers = 0
	elif n == 2 and '1' not in s:
		numbers = 1
	elif n == 2 and '1' in s:
		numbers = 0
	else:
		for i in range(n - 1, -1, -1):
			if s[i] == '0':
				if last1 - i > k:
					numbers += 1
					last1 = i
			else:
				if last1 - i <= k:
					numbers -= 1
				last1 = i
	print(numbers)


t = int(input())
for _ in range(t):
	(n, k) = (int(var) for var in input().split())
	arr = [int(var) for var in input()]
	(l, ans) = (0, 0)
	k += 1
	i = 0
	while i < n:
		if arr[i] == 1:
			r = i - k
			space = max(r - l + 1, 0)
			ans += max(1 if space > 0 else 0, space // k + min(1, space % k))
			l = i + k
			i = l
		else:
			i += 1
	if arr[-1] == 0 and l < n:
		space = n - l
		ans += max(1 if space > 0 else 0, space // k + min(1, space % k))
	print(ans)


import math
from io import BytesIO, IOBase
import sys
import os

def Iint():
	return int(input())

def Ilist():
	return list(map(int, input().split()))

def Imap():
	return map(int, input().split())

def Plist(li, s=' '):
	print(s.join(map(str, li)))

def main():
	ceil = math.ceil
	t = Iint()
	for _ in range(t):
		(n, k) = Imap()
		s = input()
		lp = -1
		ans = 0
		for (i, si) in enumerate(s):
			if si == '1':
				noes = i - lp - 1
				if lp != -1:
					if noes > 2 * k:
						noes -= 2 * k
						ans += ceil(noes / (k + 1))
				elif lp == -1:
					if noes > k:
						noes -= k
						ans += ceil(noes / (k + 1))
				lp = i
		noes = n - lp - 1
		if lp != -1:
			if noes > k:
				noes -= k
				ans += ceil(noes / (k + 1))
		else:
			ans += ceil(noes / (k + 1))
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


tc = int(input())
for _ in range(tc):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	s = '1' + k * '0' + s + k * '0' + '1'
	c = 0
	z = 0
	for i in range(len(s)):
		if s[i] == '0':
			z = z + 1
		if s[i] == '1':
			z = 0
		if z == 2 * k + 1:
			z = k
			c = c + 1
	print(c)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = input()
	ct = 0
	ll = []
	for i in range(n):
		if l[i] == '0':
			ct += 1
		else:
			ll.append(ct)
			ct = 0
	ll.append(ct)
	ans = 0
	k += 1
	if ct == n:
		ans += ll[0] // k
		if ll[0] % k > 0:
			ans += 1
		print(ans)
	else:
		for i in range(len(ll)):
			ans += ll[i] // k
			if ll[i] % k != k - 1 and i != 0 and (i != len(ll) - 1):
				ans -= 1
		print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(k, r) = (k + 1, 0)
	(l, s) = (-k, input())
	for i in range(n):
		if s[i] == '1':
			r += (i - l - k) // k
			l = i
	print(r + (n - 1 - l) // k)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	arr = []
	flag = 0
	for i in range(n):
		if s[i] == '1':
			flag = 1
			arr.append(i)
	if flag == 0:
		if n % (k + 1) == 0:
			ans = n // (k + 1)
		else:
			ans = n // (k + 1) + 1
		if ans == 0:
			ans = 1
	else:
		ans = arr[0] // (k + 1)
		for i in range(1, len(arr)):
			ans += max((arr[i] - arr[i - 1]) // (k + 1) - 1, 0)
		ans += (n - arr[-1] - 1) // (k + 1)
	print(ans)


def solve():
	(n, k) = list(map(int, input().split()))
	s = list(input())
	first = -1
	last = -1
	l = []
	for i in range(n):
		if s[i] == '1':
			l.append(i)
	if len(l) > 0:
		last = l[-1]
		first = l[0]
	if first == -1 and last == -1:
		fac = n // (k + 1)
		if n % (k + 1) != 0:
			fac += 1
		print(fac)
	else:
		ans = 0
		if first != last:
			for i in range(len(l) - 1):
				ans += max(0, (l[i + 1] - l[i]) // (k + 1) - 1)
		ans += first // (k + 1)
		ans += (n - last - 1) // (k + 1)
		print(ans)
t = 1
t = int(input())
for _ in range(t):
	solve()


import sys
input = sys.stdin.readline

def solve():
	(n, k) = [int(x) for x in input().split()]
	s = input().strip()

	def calc(l):
		if l <= 0:
			return 0
		return (l - 1) // (k + 1) + 1
	a = n - len(s.lstrip('0'))
	if a == n:
		print(calc(n))
		return
	b = n - len(s.rstrip('0'))
	arr = s.split('1')[1:-1]
	ans = calc(a - k) + calc(b - k)
	for el in arr:
		ans += calc(len(el) - 2 * k)
	print(ans)
tt = int(input())
for test in range(tt):
	solve()


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	A = input()
	i = 0
	B = []
	count = 0
	while i < len(A):
		if A[i] == '1':
			i += K + 1
		elif A[i] == '0':
			c = 0
			if i + K < len(A):
				for j in range(i, i + K + 1):
					if A[j] == '1':
						i = j + K + 1
						c += 1
						break
				if c == 0:
					count += 1
					i += K + 1
			else:
				for j in range(i, len(A)):
					if A[j] == '1':
						i = j + K + 1
						c += 1
						break
				if c == 0:
					count += 1
					i += K + 1
	print(count)


from sys import stdin
input = lambda : stdin.readline().rstrip('\r\n')

def inin():
	return int(input())

def inar():
	return list(map(int, input().split()))

class FenwickTree:

	def __init__(self, x):
		self.bit = x
		for i in range(len(x)):
			j = i | i + 1
			if j < len(x):
				x[j] += x[i]

	def update(self, idx, x):
		while idx < len(self.bit):
			self.bit[idx] += x
			idx |= idx + 1

	def query(self, end):
		x = 0
		while end:
			x += self.bit[end - 1]
			end &= end - 1
		return x
Testcase = inin()
for _ in range(Testcase):
	(n, k) = inar()
	s = input()
	tree = []
	for i in s:
		if i == '1':
			tree.append(1)
		else:
			tree.append(0)
	tree = FenwickTree(tree)
	j = 0
	for i in range(n):
		if s[i] == '1':
			break
		j += 1
	else:
		j = 0
	ans = 0
	i = 0
	while i < n:
		if s[i] == '1':
			i += 1
			continue
		li = max(0, i - k)
		ri = min(n, i + k + 1)
		if tree.query(ri) - tree.query(li) == 0 and s[i] == '0':
			ans += 1
			tree.update(i, 1)
		i += 1
	print(ans)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input()))
	if l.count(0) == n:
		print(math.ceil(n / (k + 1)))
	else:
		zl = []
		t = []
		first = 0
		last = 0
		for i in range(n):
			if l[i] == 0:
				if i == 0:
					first = 1
				t.append(0)
			else:
				if len(t) != 0:
					zl.append(t)
				t = []
		if len(t) != 0:
			zl.append(t)
			last = 1
		out = 0
		ll = []
		for i in zl:
			ll.append(len(i))
		for i in range(len(zl)):
			if first == 1:
				ll[0] -= k
				first = 0
			elif i == len(zl) - 1 and last == 1:
				ll[i] -= k
			else:
				ll[i] -= 2 * k
		for i in ll:
			if i >= 0:
				out += math.ceil(i / (k + 1))
		print(out)


import sys
import math
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
for t in range(int(input())):
	(n, k) = intInp()
	s = input()
	s = '1' + '0' * k + s + '0' * k + '1'
	last = 0
	ans = 0
	for i in range(1, len(s)):
		if s[i] == '1':
			dis = i - last - 1
			dis -= 2 * k
			for j in range(0, dis, k + 1):
				ans += 1
			last = i
	print(ans)


import sys
input = sys.stdin.readline
for T in range(int(input())):
	(n, m) = list(map(int, input().split()))
	s = input().strip()
	r = [m] * (n + 1)
	k = n
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			r[i] = 0
			k = i
		else:
			r[i] = r[i + 1] + 1
	l = -m - 1
	cnt = 0
	for i in range(n):
		if i - l == m + 1 and r[i] >= m + 1:
			l = i
			cnt += 1
		elif r[i] == 0:
			l = i
	print(cnt)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	d = [0] * n
	s1 = -1
	i = 0
	while i < n:
		if s[i] == '1':
			j = i + k
			while i < n and i <= j:
				d[i] = -1
				if s[i] == '1':
					j = i + k
				i += 1
		else:
			i += 1
	i = n - 1
	while i > -1:
		if s[i] == '1':
			j = i - k
			while i > -1 and i >= j:
				d[i] = -1
				if s[i] == '1':
					j = i - k
				i -= 1
		else:
			i -= 1
	i = 0
	ans = 0
	while i < n:
		if d[i] == 0:
			s0 = i
			while i < n and d[i] == 0:
				i += 1
			ans += (i - s0) // (k + 1)
			if (i - s0) % (k + 1) != 0:
				ans += 1
		else:
			i += 1
	print(ans)


for z in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	seg = 2 * k + 1
	total = 0
	val = 0
	if s[0] == '0':
		for i in range(min(n, k + 1)):
			total += ord(s[i]) - ord('0')
		if total == 0:
			val += 1
			s[0] = '1'
	total = 0
	if s[n - 1] == '0':
		i = n - 1
		while i >= max(n - 1 - k, 0):
			total += ord(s[i]) - ord('0')
			i -= 1
		if total == 0:
			val += 1
			s[n - 1] = '1'
	total = 0
	for i in range(n):
		total += ord(s[i]) - ord('0')
		if i >= seg - 1:
			if total == 0:
				val += 1
				s[i - k] = '1'
				total += 1
			if s[i - seg + 1] == '1':
				total -= 1
	print(val)


import sys
scan = sys.stdin.readline
from math import *
from random import randint
from collections import deque
tt = int(scan())
for test in range(tt):
	x = scan()
	ara = x.split()
	n = int(ara[0])
	k = int(ara[1])
	lst = []
	val = 0
	ch = scan()
	for i in range(n):
		if ch[i] == '1':
			lst.append(i)
	if len(lst) == 0:
		val = int(n / (k + 1))
		if n % (k + 1):
			val = val + 1
	else:
		val += lst[0] / (k + 1)
		for i in range(1, len(lst), 1):
			v = lst[i] - lst[i - 1] - 1
			if v - k >= 0:
				val += int((v - k) / (k + 1))
		w = n - lst[len(lst) - 1] - 1
		val += int(w / (k + 1))
	print(int(val))


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	s = str(input())
	array = [2 for j in range(n)]
	for j in range(n):
		if s[j] == '1':
			array[j] = 1
			for l in range(max(0, j - k), j):
				array[l] = 0
			for r in range(j + 1, min(j + k + 1, n)):
				array[r] = 0
	count = 0
	for j in range(n):
		if array[j] == 2:
			array[j] = 1
			count += 1
			for l in range(max(0, j - k), j):
				array[l] = 0
			for r in range(j + 1, min(j + k + 1, n)):
				array[r] = 0
	print(count)


from sys import stdin, stdout, setrecursionlimit
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = input()
	s = '1' + '0' * k + s + '0' * k + '1'
	cou = 0
	a = []
	for i in range(len(s)):
		if s[i] == '1':
			a.append(i)
	for i in range(1, len(a)):
		cou += (a[i] - a[i - 1] - 1 - k) // (k + 1)
	print(cou)


import sys

def main():
	t = int(next(sys.stdin))
	for _ in range(t):
		a = next(sys.stdin)
		(_, k) = list(map(int, a.split()))
		b = next(sys.stdin)
		s = b.strip()
		print(solve(s, k))

def solve(s, k):
	segs = []
	n = len(s)
	last = -n - 1
	x = 0
	for i in range(n):
		if s[i] == '0':
			if i - k > last:
				x += 1
		else:
			if i - k > last:
				if x - k > 0:
					segs.append(x - k)
			last = i
			x = 0
	if x > 0:
		segs.append(x)
	ans = sum(((x + k) // (k + 1) for x in segs))
	return ans
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('1', 1) == 0
assert solve('0', 1) == 1
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	a = 0
	ans = 0
	first = True
	for i in range(n):
		if s[i] == '0':
			a += 1
		else:
			if first:
				ans += a // (k + 1)
				first = False
			elif a >= 2 * k + 1:
				ans += (a - k) // (k + 1)
			a = 0
	if first:
		ans = 1 + (a - 1) // (k + 1)
	else:
		ans += a // (k + 1)
	print(ans)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	ans = 0
	dis = k
	for i in range(n):
		if s[i] == '0':
			dis += 1
		else:
			dis = 0
		if dis == 2 * k + 1:
			ans += 1
			dis = k
	if dis >= k + 1:
		ans += 1
	print(ans)


m = 10 ** 9 + 7
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	s = input()
	p = []
	for i in range(n):
		if s[i] == '1':
			p.append(i)
	if len(p) == 0:
		print(1 + (n - 1) // (k + 1))
		continue
	ans = 0
	for i in range(1, len(p)):
		ans += (p[i] - p[i - 1]) // (k + 1) - 1
	ans += p[0] // (k + 1) + (n - p[-1] - 1) // (k + 1)
	print(ans)


import math

def add(space, distance):
	return max(0, math.floor(space / (distance + 1)) - 1)
t = int(input())
for case in range(t):
	(n, distance) = list(map(int, input().split(' ')))
	last_occupied = -distance - 1
	index = 0
	result = 0
	arr = list(input())
	for state in arr:
		if state == '1':
			result += add(index - last_occupied, distance)
			last_occupied = index
		index += 1
	result += add(n + distance - last_occupied, distance)
	print(result)


nb_cases = int(input())
while nb_cases > 0:
	nb_cases -= 1
	(n, k) = [int(x) for x in input().split()]
	s = input()
	suite0 = []
	nb_tables_ajout = 0
	suite_en_cours = 0
	for b in range(n):
		if s[b] == '0':
			suite_en_cours += 1
		else:
			suite0.append(suite_en_cours)
			suite_en_cours = 0
	suite0.append(suite_en_cours)
	while 0 in suite0:
		suite0.remove(0)
	if len(suite0) == 0:
		nb_tables_ajout = 0
	elif len(suite0) == 1:
		if suite0[0] == n:
			nb_tables_ajout = 1 + int((suite0[0] - 1) / (k + 1))
		elif s[0] == '0' or s[n - 1] == '0':
			nb_tables_ajout = int(suite0[0] / (k + 1))
		else:
			nb_tables_ajout = int((suite0[0] - k) / (k + 1))
	else:
		if s[0] == '0':
			nb_tables_ajout = int(suite0[0] / (k + 1))
			suite0 = suite0[1:]
		if s[n - 1] == '0':
			nb_tables_ajout += int(suite0[len(suite0) - 1] / (k + 1))
			suite0 = suite0[:-1]
		for x in range(0, len(suite0)):
			nb_tables_ajout += int((suite0[x] - k) / (k + 1))
	print(nb_tables_ajout)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = input()
	prev_idx = 0
	next_idx = 0
	count = 0
	if s[:k + 1].__contains__('1'):
		prev_idx = s[:k + 1].find('1') + 1
	else:
		count += 1
		prev_idx = 1
	dist = 2 * k + 1
	for i in range(prev_idx + 1, len(s)):
		next_idx = i
		if next_idx - prev_idx == dist:
			prev_idx = next_idx - k
			count += 1
		if s[i] == '1':
			prev_idx = i + 1
	if len(s) - prev_idx >= k + 1:
		count += 1
	print(count)


from math import ceil

def help():
	(n, k) = map(int, input().split(' '))
	ll = list(input())
	arr = [0] * n
	for i in range(n):
		if ll[i] == '1':
			for j in range(i - k, i + k + 1):
				if j < 0 or j >= n:
					continue
				arr[j] = -1
	done = 0
	curr = 0
	for i in range(n):
		if arr[i] == -1:
			done += ceil(curr / (k + 1))
			curr = 0
		else:
			curr += 1
	done += ceil(curr / (k + 1))
	print(done)
for _ in range(int(input())):
	help()


import bisect as bi
test_cases = int(input())
for _ in range(test_cases):
	(size, k) = map(int, input().split())
	arr = input()
	m = []
	n = []
	for i in range(len(arr)):
		if arr[i] == '1':
			m.append(i)
		else:
			n.append(i)
	count = 0
	if not len(m):
		m.append(n[0])
		count += 1
	m.append(1000000)
	for i in range(len(n)):
		index = bi.bisect_left(m, n[i] + k)
		ind = bi.bisect_right(m, n[i] + k)
		if index == 0 and m[index] > n[i] + k:
			bi.insort(m, n[i])
			count += 1
		elif m[index - 1] + k < n[i] and m[index] > n[i] + k:
			bi.insort(m, n[i])
			count += 1
	print(count)


import sys

def multiple_input():
	return map(int, sys.stdin.readline().strip().split())

def list_input():
	return list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	(n, k) = multiple_input()
	a = input()
	(i, ans) = (0, 0)
	while i < n:
		if a[i] == '1':
			i += k + 1
		else:
			end = i + k
			while i < n and i <= end:
				if a[i] == '0':
					i += 1
				else:
					break
			if i == end + 1 or i == n:
				ans += 1
	print(ans)


import math, collections, bisect
for testcase in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	(start, mid, last) = (0, [], 0)
	if int(s, 2) == 0:
		print(math.ceil(len(s) / (k + 1)))
	else:
		num1 = s.count('1')
		i = 0
		ans = []
		(right, left) = (0, 0)
		flag = 0
		while i < len(s):
			left = i
			while i < len(s) and s[i] == '0':
				i += 1
				flag = 1
			right = i
			if flag:
				ans.append(right - left)
			i += 1
		(x, y) = (0, 0)
		if s[0] == '0':
			ans[0] = max(ans[0] - k, 0)
			x = 1
		if s[-1] == '0':
			ans[-1] = max(ans[-1] - k, 0)
			y = 1
		count = 0
		for i in range(x, len(ans) - y):
			ans[i] = max(ans[i] - 2 * k, 0)
		for num_zero in ans:
			count += math.ceil(num_zero / (k + 1))
		print(count)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = input()
	c = 0
	x = 0
	x1 = 0
	x2 = 0
	ans = 0
	b = []
	for j in range(n):
		if a[j] == '0':
			x = j
			break
	for j in range(n):
		if a[j] == '1':
			x1 = j
			break
	for j in range(n):
		if a[j] == '1':
			x2 = j
	if x1 != x2:
		for j in range(x1 + 1, x2 + 1):
			if a[j] == '0':
				c += 1
			else:
				b.append(c)
				c = 0
	if a.count('1') == 0:
		for j in range(0, n, k + 1):
			ans += 1
	else:
		for j in range(x1 - k - 1, -1, -k - 1):
			ans += 1
		for j in range(x2 + k + 1, n, k + 1):
			ans += 1
		for y in b:
			for j in range(k, y - k, k + 1):
				ans += 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
for _ in range(int(ri())):
	(n, k) = Ri()
	a = ri()
	close = -INF
	ans = 0
	right = [0] * (n + 1)
	right[n] = INF
	for i in range(len(a) - 1, -1, -1):
		if a[i] == '1':
			right[i] = i
		else:
			right[i] = right[i + 1]
	for i in range(len(a)):
		if a[i] == '0':
			if abs(i - close) >= k + 1 and abs(i - right[i]) >= k + 1:
				ans += 1
				close = i
		else:
			close = i
	print(ans)


q = int(input())
while q > 0:
	inp = input().split(' ')
	n = int(inp[0])
	k = int(inp[1])
	sits = input()
	(i, c) = (0, 0)
	permit = False
	if k == n:
		if '1' in sits:
			c = 0
			n = -5
		else:
			c = 1
			n = -5
	while i < n:
		if i < n - k - 1:
			if sits[i] == '1':
				i += k + 1
				permit = True
			elif sits[i] == '0' and '1' not in sits[i + 1:i + 1 + k]:
				c += 1
				i += k + 1
				permit = True
		elif sits[i] == '1':
			break
		elif sits[i] == '0' and '1' not in sits[i:]:
			c += 1
			break
		if permit == False:
			i += 1
		permit = False
	print(c)
	q -= 1


import math
for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	ans = 0
	c = []
	cnt = 0
	for i in range(n):
		if s[i] == '0':
			cnt += 1
		else:
			c.append(cnt)
			cnt = 0
	if s[n - 1] != '1':
		c.append(cnt)
	else:
		c.append(0)
	if len(c) == 1:
		print(math.ceil(c[0] / (k + 1)))
	else:
		ans = math.ceil((c[0] - k) / (k + 1)) + math.ceil((c[len(c) - 1] - k) / (k + 1))
		for i in range(1, len(c) - 1):
			if math.ceil((c[i] - 2 * k) / (k + 1)) >= 0:
				ans += math.ceil((c[i] - 2 * k) / (k + 1))
		print(ans)


import math
from decimal import *
getcontext().prec = 30
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	s = input()
	last = -k - 1
	ans = 0
	s += '0' * k + '1'
	for i in range(len(s)):
		if s[i] == '1':
			l = i - last - 1
			act = l - 2 * k
			last = i
			if act <= 0:
				continue
			else:
				ans += math.ceil(act / (k + 1))
	print(ans)


def count(a, b, k):
	d = a - b - k
	if d % (k + 1) == 0:
		return d // (k + 1) - 1
	return d // (k + 1)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	m = [-k - 1]
	for c in range(n):
		if s[c] == '1':
			m.append(c)
	m.append(n + k)
	if len(m) == 2:
		print((n - 1) // (k + 1) + 1)
	else:
		c = 0
		for i in range(1, len(m)):
			c += max(0, count(m[i], m[i - 1], k))
		print(c)


def values(n, k, flag):
	if flag == 1:
		return int((n + k) / (k + 1))
	elif flag == 2:
		return int((n - k) / (k + 1))
	else:
		return int(n / (k + 1))
t = int(input())
for i in range(t):
	arr = [int(i) for i in input().split()]
	n = arr[0]
	k = arr[1]
	sit = input()
	loca = []
	flag = False
	for j in range(n):
		if sit[j] == '1':
			loca.append(j)
			flag = True
	if flag == False:
		print(values(n, k, flag=1))
	else:
		res = 0
		for index in range(len(loca)):
			if index == 0:
				res = res + values(loca[index], k, flag=3)
			if index == len(loca) - 1:
				res = res + values(n - loca[index] - 1, k, flag=3)
			if index != len(loca) and index != 0:
				res = res + values(loca[index] - loca[index - 1] - 1, k, flag=2)
		print(res)


import os
from math import *
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	z = 0
	count = 0
	for i in range(n):
		if s[i] == '1':
			if z == 0:
				ans += count // (k + 1)
				z = 1
			else:
				c = count - k - k
				if c <= 0:
					ans += 0
				elif c < k:
					ans += 1
				else:
					ans += 1 + (c - 1) // (k + 1)
			count = 0
		else:
			count += 1
	if '1' not in s:
		if len(s) <= k:
			print('1')
		else:
			print(1 + (n - 1) // (k + 1))
	else:
		print(ans + count // (k + 1))


import sys
input = sys.stdin.readline
LI = lambda : list(map(int, input().split()))
MI = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, k) = MI()
	s = input().strip('\n')
	ind = []
	for (i, c) in enumerate(s):
		if c == '1':
			ind.append(i)
	if ind:
		ans = ind[0] // (k + 1) + (n - 1 - ind[-1]) // (k + 1)
		for i in range(1, len(ind)):
			ans += (ind[i] - ind[i - 1] - k - 1) // (k + 1) if ind[i] - ind[i - 1] - k - 1 >= 0 else 0
	else:
		ans = 1 + (n - 1) // (k + 1)
	print(ans)


t = int(input())
for y in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	s = input()
	nxtR = [1 for i in range(n + 2)]
	nxtR[n] = k + 5
	i = n - 1
	while i >= 0:
		nxtR[i] = nxtR[i + 1] + 1
		if s[i] == '1':
			nxtR[i] = 0
		i -= 1
	dist = k + 5
	ans = 0
	for i in range(n):
		if min(nxtR[i], dist) > k:
			dist = 0
			ans += 1
		if s[i] == '1':
			dist = 0
		dist += 1
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	s = input().strip()
	fast = 10000000
	slow = -10000000
	ans = 0
	for (index, i) in enumerate(s):
		if i == '1':
			fast = index
			break
	for (index, i) in enumerate(s):
		if i == '1':
			slow = index
			for j in range(index + 1, len(s)):
				if s[j] == '1':
					fast = j
					break
		elif abs(index - slow) > k and abs(fast - index) > k:
			ans += 1
			slow = index
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = input()
	s = []
	for i in range(n):
		if l[i] == '1':
			s.append(i)
	count = 0
	if s == []:
		count += (n + k) // (k + 1)
	else:
		count += s[0] // (k + 1)
		count += (n - 1 - s[-1]) // (k + 1)
		for i in range(len(s) - 1):
			if s[i + 1] - s[i] >= 2 * k + 1:
				count += (s[i + 1] - s[i] - 1 - k) // (k + 1)
	print(count)


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


t = 1
t = int(input())
while t:
	t -= 1
	(n, k) = list(map(int, input().split()))
	s = input()
	ans = 0
	start = s.find('1')
	end = s.rfind('1')
	if start != -1:
		ans += start // (k + 1)
		ans += (n - end - 1) // (k + 1)
		indexes = []
		for i in range(n):
			if s[i] == '1':
				indexes.append(i)
		distances = []
		for i in range(1, len(indexes)):
			distances.append(max(indexes[i] - indexes[i - 1] - 1, 0))
		for dist in distances:
			ans += max((dist + 1) // (k + 1) - 1, 0)
	else:
		ans = max(1, (n + k) // (k + 1))
	print(ans)


import sys
import math
from collections import defaultdict as dft
input = sys.stdin.readline

def ml():
	return list(map(int, input().split()))

def mp():
	return map(int, input().split())

def debug(name, val):
	print(name, ':', val)

def update(i, val, n, BIT):
	while i <= n:
		BIT[i] += val
		i += i & -i

def que(i, n, BIT):
	sm = 0
	while i > 0:
		sm += BIT[i]
		i -= i & -i
	return sm

def solve():
	(n, k) = mp()
	ls = input()
	ans = 0
	BIT = [0] * (n + 1)
	for i in range(1, n + 1):
		if int(ls[i - 1]):
			update(i, int(ls[i - 1]), n, BIT)
	for i in range(n):
		if ls[i] == '0':
			i += 1
			total = que(i, n, BIT)
			if i > k:
				ch1 = total - que(i - k - 1, n, BIT)
			else:
				ch1 = total
			if i + k <= n:
				ch2 = que(i + k, n, BIT) - total
			else:
				ch2 = que(n, n, BIT) - total
			if ch1 == 0 and ch2 == 0:
				ans += 1
				update(i, 1, n, BIT)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


test_cases = int(input())
for _ in range(test_cases):
	(n, k) = map(int, input().split())
	s = input()
	occupable = 0
	i = 0
	while i < len(s):
		if s[i] == '1':
			i += k + 1
		else:
			j = i + 1
			canOccupy = True
			while j < len(s) and j < i + k + 1:
				if s[j] == '1':
					canOccupy = False
					break
				j += 1
			if canOccupy:
				occupable += 1
			assert j > i
			i = j
	print(occupable)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	p = input()
	l = []
	r = 0
	for j in range(a):
		if p[j] == '1':
			l.append(j)
	if l == []:
		if a % (b + 1) == 0:
			r = a // (b + 1)
		else:
			r = a // (b + 1)
			r += 1
		print(r)
		continue
	for j in range(1, len(l)):
		h = l[j] - l[j - 1] - 1 - 2 * b
		if h > 0:
			if h % (b + 1) == 0:
				r += h // (b + 1)
			else:
				r += 1
				r += h // (b + 1)
	g = l[0] - b
	if g % (b + 1) == 0:
		r += g // (b + 1)
	else:
		r += 1
		r += g // (b + 1)
	gg = a - 1 - l[-1] - b
	if gg % (b + 1) == 0:
		r += gg // (b + 1)
	else:
		r += gg // (b + 1)
		r += 1
	print(r)


def func(c, k):
	a = c // (k + 1)
	if c % (k + 1) >= 1:
		a += 1
	return a
t = int(input())
for tp in range(t):
	(n, k) = map(int, input().split())
	s = input()
	s = list(s)
	ans = 0
	for i in range(len(s)):
		if s[i] == '0' or s[i] == '5':
			continue
		else:
			for j in range(i + 1, min(i + k + 1, len(s))):
				if s[j] == '0':
					s[j] = '5'
				elif s[j] == '1':
					break
			for j in range(i - 1, max(-1, i - k - 1), -1):
				if s[j] == '0':
					s[j] = '5'
				elif s[j] == '1':
					break
	counter = 0
	for i in range(len(s)):
		if s[i] == '0':
			counter += 1
		else:
			ans += func(counter, k)
			counter = 0
	ans += func(counter, k)
	print(ans)


import sys
from collections import defaultdict
TEST = 0
if TEST == 1:
	input_file = open('inputC.txt', 'r')
	input_from_file = input_file.readlines()

def read_int():
	if TEST:
		return int(input_from_file.pop(0))
	else:
		return int(sys.stdin.readline())

def read_ints():
	if TEST:
		return list(map(int, input_from_file.pop(0).rstrip().split()))
	else:
		return list(map(int, sys.stdin.readline().split()))

def read_str():
	if TEST:
		in1 = input_from_file.pop(0).rstrip()
	else:
		in1 = sys.stdin.readline().rstrip()
	return in1

def addStol(nuley, k, leftbound, rightbound):
	dopmest = nuley // (k + 1)
	if leftbound and rightbound:
		if nuley % (k + 1) < k:
			dopmest -= 1
			dopmest = max(0, dopmest)
	elif leftbound == False and rightbound == False:
		if nuley > dopmest * (k + 1):
			dopmest += 1
	return dopmest
tests = read_int()
for test in range(tests):
	(n, k) = read_ints()
	s = read_str()
	stolikov = 0
	nuley = 0
	leftbound = False
	for j in range(len(s)):
		if s[j] == '1':
			stolikov += addStol(nuley, k, leftbound, True)
			nuley = 0
			leftbound = True
		else:
			nuley += 1
	stolikov += addStol(nuley, k, leftbound, False)
	print(stolikov)


def main():
	for _ in range(int(input())):
		(n, k) = list(map(int, input().split()))
		s = input()
		a = [i for i in range(len(s)) if s[i] == '1']
		x = []
		for i in range(len(a) - 1):
			x.append(s[a[i] + 1:a[i + 1]])
		s1 = 0
		for i in x:
			y = len(range(k, len(i) + 1, k + 1)) - 1
			s1 += y if y > 0 else 0
		if len(a) > 0:
			y = len(range(0, a[0] + 1, k + 1)) - 1
			s1 += y if y > 0 else 0
			y = len(range(n - 1, a[-1] - 1, -k - 1)) - 1
			s1 += y if y > 0 else 0
			print(s1)
		else:
			y = len(range(0, n, k + 1))
			s1 += y if y > 0 else 0
			print(s1)
main()


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))


cases = int(input())
for v in range(cases):
	a = list(map(int, input().strip().split()))
	n = a[0]
	k = a[1]
	a = input()
	k = k + 1
	i = 0
	cnt = 0
	f = 0
	while i < n:
		if a[i] == '1':
			i = i + k
		else:
			p = i + k
			while i < n and i < p:
				if a[i] == '1':
					f = 1
					break
				i = i + 1
			if f == 1:
				f = 0
				continue
			else:
				cnt += 1
				i = p
	print(cnt)


t = int(input())
for i in range(t):
	txt = input().split(' ')
	(n, k) = (int(txt[0]), int(txt[1]))
	s = input()
	(a, d) = (0, 0)
	for j in range(n):
		if int(s[j]) == 0:
			d += 1
			if j == 0:
				d += k
			if j == n - 1:
				d += k
			if d > 2 * k:
				d = k
				a += 1
		else:
			d = 0
	print(a)


import sys
input = sys.stdin.readline

def prog():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		line = input().strip()
		placed = 0
		length = 0
		found = False
		for i in range(n):
			if line[i] == '1':
				found = True
				break
		l = i - found
		found = False
		for i in range(n - 1, -1, -1):
			if line[i] == '1':
				found = True
				break
		r = i + found
		if r <= l:
			length = n
			length -= 1
			placed += 1 + length // (k + 1)
		else:
			lengths = [l + 1, n - r]
			for length in lengths:
				length -= k + 1
				if length >= 0:
					placed += 1 + length // (k + 1)
		length = 0
		for i in range(l + 1, r):
			if line[i] == '1':
				length -= 2 * k + 1
				if length >= 0:
					placed += 1 + length // (k + 1)
				length = 0
			else:
				length += 1
		print(placed)
prog()


def mark(used, i, k):
	start = i - k if i - k > 0 else 0
	end = i + k + 1 if i + k + 1 < len(used) else len(used)
	for id in range(start, end):
		used[id] = True
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	counter = 0
	used = [False for _ in range(len(s))]
	for i in range(len(s)):
		if s[i] == '1':
			mark(used, i, k)
	for i in range(len(s)):
		if not used[i]:
			mark(used, i, k)
			counter += 1
	print(counter)


from math import *
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	tables = ('0' * k + input() + '0' * k).split('1')
	contig0 = 0
	ans = 0
	ones = 0
	for j in tables:
		contig0 = max(len(j) - k, 0)
		ans += contig0 // (k + 1)
	print(ans)


import sys, math

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 _ in range(int(input())):
	(n, k) = get_ints()
	S = '0' * k + get_string() + '0' * k
	L = S.split('1')
	count = 0
	for i in L:
		count += max((len(i) - k) // (k + 1), 0)
	print(count)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	l = []
	ans = 0
	for j in range(n):
		if s[j] == '1':
			l.append(j + 1)
	if len(l) == 0:
		a = ''
		for j in range(n):
			if j % (k + 1) == 0:
				a += '1'
			else:
				a += '0'
		print(a.count('1'))
	else:
		ans += (l[0] - 1) // (k + 1)
		x = len(l) - 1
		ans += (n - l[x]) // (k + 1)
		for j in range(1, len(l)):
			ans += (l[j] - l[j - 1]) // (k + 1) - 1
		print(ans)


from sys import stdin, stdout
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()
import math
from collections import Counter

def solve():
	(n, k) = MAP()
	s = S()
	a = list(s)
	b = [int(a[0])]
	for i in range(1, n):
		b.append(b[-1] + int(a[i]))
	for i in range(k):
		b.append(b[n - 1])
	x = 0
	i = 0
	while n > i:
		if s[i] == '0':
			if b[i + k] == b[i]:
				x += 1
				i += k + 1
			else:
				i += 1
		else:
			i += k + 1
	print(x)
for i in range(IN()):
	solve()


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		s = input()
		ok = True
		for i in s:
			if i == '1':
				ok = False
				break
		ct = 0
		if ok:
			for i in range(0, n, k + 1):
				ct += 1
			print(ct)
			continue
		f = -1
		for i in range(n):
			if s[i] == '1':
				f = i
				break
		pos = f
		f -= k
		for i in range(0, f, k + 1):
			ct += 1
		l = 0
		for i in range(n - 1, -1, -1):
			if s[i] == '1':
				l = n - 1 - i
				break
		l -= k
		for i in range(0, l, k + 1):
			ct += 1
		j = pos
		for i in range(j + 1, n):
			if s[i] == '1':
				rem = i - j - 1
				ct += rem // (k + 1)
				if rem % (k + 1) != k:
					ct -= 1
				j = i
		print(ct)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ar = []
	for i in range(n):
		if s[i] == '1':
			ar.append(i)
	al = len(ar)
	ans = 0
	if al == 0:
		ans = 1 + (n - 1) // (k + 1)
	else:
		ans = ar[0] // (k + 1) + max(0, n - ar[-1] - 1) // (k + 1)
		if al > 1:
			for i in range(al - 1):
				ans += max(ar[i + 1] - ar[i] - 1 - k, 0) // (k + 1)
	print(ans)


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


from math import inf
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	dp = [inf for i in range(n)]
	cur1 = inf
	for i in range(n - 1, -1, -1):
		dp[i] = cur1
		if s[i] == '1':
			cur1 = i
	i = 0
	ans = 0
	while i < n:
		if s[i] == '1':
			i += k + 1
		elif dp[i] >= i + k + 1:
			ans += 1
			i = i + k + 1
		else:
			i = dp[i]
	print(ans)


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
for _ in range(int(input())):
	(n, k) = ilele()
	s = input()
	if n <= k + 1:
		if '1' in s:
			print(0)
		else:
			print(1)
	else:
		count = 0
		T = [list(j) for (i, j) in groupby(s)]
		t = len(T)
		Ans = 0
		for i in range(t):
			if T[i][0] == '0':
				if i == 0 and i == t - 1:
					Ans += math.ceil(len(T[i]) / (k + 1))
				elif i == 0 or i == t - 1:
					Ans += len(T[i]) // (k + 1)
				else:
					m = len(T[i]) - 2 * k
					if m > 0:
						Ans += math.ceil(m / (k + 1))
		print(Ans)


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	n = a[0]
	k = a[1]
	st = input()
	flag = 0
	ans = 0
	arr = []
	temp = 0
	siz = len(st)
	for j in range(siz):
		if j == siz - 1:
			if st[j] == '0':
				arr.append(temp + 1)
				flag = 1
			else:
				arr.append(temp)
		elif st[j] == '0':
			temp += 1
		else:
			arr.append(temp)
			temp = 0
	t = len(arr)
	if t == 1:
		if flag == 1:
			if siz % (k + 1) == 0:
				ans = siz // (k + 1)
			else:
				ans = siz // (k + 1) + 1
		elif (siz - k - 1) % (k + 1) == 0:
			ans = (siz - k - 1) // (k + 1)
		else:
			ans = (siz - k - 1) // (k + 1) + 1
	elif flag == 0:
		for j in range(t):
			if j == 0:
				if (arr[j] - k) % (k + 1) == 0:
					ans += (arr[j] - k) // (k + 1)
				else:
					ans += (arr[j] - k) // (k + 1) + 1
			elif arr[j] - 2 * k > 0:
				if (arr[j] - 2 * k) % (k + 1) == 0:
					ans += (arr[j] - 2 * k) // (k + 1)
				else:
					ans += (arr[j] - 2 * k) // (k + 1) + 1
	else:
		for j in range(t):
			if j == 0:
				if (arr[j] - k) % (k + 1) == 0:
					ans += (arr[j] - k) // (k + 1)
				else:
					ans += (arr[j] - k) // (k + 1) + 1
			elif j == t - 1:
				if (arr[j] - k) % (k + 1) == 0:
					ans += (arr[j] - k) // (k + 1)
				else:
					ans += (arr[j] - k) // (k + 1) + 1
			elif arr[j] - 2 * k > 0:
				if (arr[j] - 2 * k) % (k + 1) == 0:
					ans += (arr[j] - 2 * k) // (k + 1)
				else:
					ans += (arr[j] - 2 * k) // (k + 1) + 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input()))
	ans = [0] * n
	i = 0
	j = 0
	m = 0
	if 1 in A[:k + 1]:
		i = A.index(1)
		l = -1
	else:
		m += 1
		l = 1
	i += 1
	while i != n:
		if A[i] == 1:
			if l != -1 and j != k:
				m -= 1
			j = 0
			l = -1
		elif j == k:
			j = 0
			l = 1
			m += 1
		else:
			j += 1
		i += 1
	print(m)


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	num_ones = sum([int(x) for x in s])
	ans = 0
	if num_ones == 0:
		if len(s) <= k:
			ans = 1
		else:
			ans += len(s) // (k + 1)
			if len(s) % (k + 1):
				ans += 1
	else:
		ones = []
		for i in range(n):
			if s[i] == '1':
				ones.append(i)
		if ones[0] > k:
			ans += (ones[0] - k) // (k + 1)
			if (ones[0] - k) % (k + 1):
				ans += 1
		for i in range(len(ones) - 1):
			if ones[i] + k + 1 < ones[i + 1] - k:
				ans += (ones[i + 1] - ones[i] - 2 * k - 1) // (k + 1)
				if (ones[i + 1] - ones[i] - 2 * k - 1) % (k + 1):
					ans += 1
		if len(s) - 1 - ones[-1] > k:
			ans += (len(s) - 1 - ones[-1] - k) // (k + 1)
			if (len(s) - 1 - ones[-1] - k) % (k + 1):
				ans += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	t = [True] * n
	c = 0
	for i in range(n):
		if s[i] == '1':
			for j in range(i - k, i + k + 1):
				if j >= 0 and j < n:
					t[j] = False
	for i in range(n):
		if t[i] == True:
			c += 1
			for j in range(i - k, i + k + 1):
				if j >= 0 and j < n:
					t[j] = False
	print(c)


from fractions import Fraction
import bisect
import os
import io
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = 1
t = iinput()
for _ in range(t):
	(n, k) = rinput()
	s = input()
	if s.count('0') == n:
		print(int(math.ceil(n / float(k + 1))))
		continue
	ans = 0
	i = 0
	while i < n:
		zero = 0
		start = i
		while i < n and s[i] == '0':
			i += 1
			zero += 1
		if start != 0 and i < n and (s[i] == '1'):
			ans += (zero - k) // (k + 1)
		else:
			ans += zero // (k + 1)
		i += 1
	print(ans)


import sys

def solve(s, k):
	n = len(s)
	a = [1 if s[i] == '1' else 0 for i in range(n)]
	if sum(a) == 0:
		return 1 + (n - 1) // (k + 1)
	tot = 0
	run = 0
	i = 0
	while i < n:
		if a[i] == 0:
			i += 1
			run += 1
		else:
			i += 1
			break
	if run > 0:
		tot += run // (k + 1)
	run = 0
	while i < n:
		if a[i] == 0:
			run += 1
		else:
			if run >= k:
				tot += (run - k) // (k + 1)
			run = 0
		i += 1
	if run > 0:
		tot += run // (k + 1)
	return tot

def solve_ignore(s, k):
	n = len(s)
	a = [1 if s[i] == '1' else 0 for i in range(n)]
	DIST_l = [0] * n
	DIST_l[0] = -1 if a[0] == 1 else k + 1
	for i in range(1, n):
		DIST_l[i] = -1 if a[i] == 1 else DIST_l[i - 1] + 1
	DIST_r = [0] * n
	DIST_r[-1] = -1 if a[-1] == 1 else k + 1
	for i in range(n - 2, -1, -1):
		DIST_r[i] = -1 if a[i] == 1 else DIST_r[i + 1] + 1
	cand_inds = [i for i in range(n) if DIST_l[i] >= k and DIST_r[i] >= k]
	if len(cand_inds) == 0:
		return 0
	NC = len(cand_inds)
	DP_y = [0] * NC
	DP_y[0] = 1
	DP_n = [0] * NC
	for ci in range(1, NC):
		DP_y[ci] = (DP_n[ci - 1] if DIST_l[ci] >= k else max([DP_y[ci - 1], DP_n[ci - 1]])) + 1
		DP_n[ci] = DP_n[ci]
	print('Y=', DP_y)
	print('N=', DP_n)
	return max(DP_y[-1], DP_n[-1])
IN = [x.strip() for x in sys.stdin.readlines()]
T = int(IN[0])
cur = 1
for ti in range(T):
	(n, k) = [int(x) for x in IN[cur].split(' ')]
	ops = []
	s = IN[cur + 1]
	result = solve(s, k)
	print(result)
	cur += 2


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
ans = []
for _ in range(ii()):
	(n, k) = mi()
	s = input()
	ind = []
	for i in range(n):
		if s[i] == '1':
			ind.append(i)
	if ind:
		t = 0
		t += ind[0] // (k + 1)
		for i in range(len(ind) - 1):
			if ind[i + 1] - ind[i] - 1 - k <= 0:
				continue
			else:
				t += (ind[i + 1] - ind[i] - 1 - k) // (k + 1)
		t += (n - ind[-1] - 1) // (k + 1)
		ans.append(t)
	else:
		ans.append(math.ceil(n / (k + 1)))
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = ['0'] * k
	arr.extend(list(input().strip()))
	arr.extend(['0'] * k)
	count = 0
	count_ones = 0
	for i in range(2 * k + 1):
		if arr[i] == '1':
			count_ones += 1
	if count_ones == 0:
		count += 1
		arr[k] = '1'
		count_ones += 1
	for i in range(2 * k + 1, len(arr)):
		if arr[i] == '1':
			count_ones += 1
		if arr[i - 2 * k - 1] == '1':
			count_ones -= 1
		if count_ones == 0:
			count += 1
			arr[i - k] = '1'
			count_ones += 1
	print(count)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	s = input()
	po = -1
	c = 0
	for i in range(n):
		if s[i] == '1':
			if po == -1:
				c += max(0, i // (k + 1))
			elif i - po - 1 - k > 0:
				c += max(0, (i - po - 1 - k) // (k + 1))
			po = i
	if po == -1:
		c += 1
		po = 0
	if n - 1 - po > 0:
		c += max(0, (n - 1 - po) // (k + 1))
	print(c)
	t -= 1


def solve(n, k, s):
	track = []
	track.append(1 - (k + 1))
	for i in range(n):
		if s[i] == '1':
			track.append(i + 1)
	track.append(n + (k + 1))
	cnt = 0
	for j in range(len(track) - 1):
		x = track[j + 1] - track[j]
		cnt += x // (k + 1) - 1
	print(cnt)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	solve(n, k, s)


def solve(s, k):
	summ = 0
	zeros = 0
	if s[0] != '1':
		s = '1' + '0' * k + s
	if s[len(s) - 1] != '1':
		s = s + '0' * k + '1'
	for i in range(len(s)):
		if s[i] != '1':
			zeros += 1
		else:
			if zeros > k:
				summ += (zeros - k) // (k + 1)
			zeros = 0
	print(summ)
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	s = input()
	solve(s, k)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s1 = '1' + '0' * k + input() + '0' * k + '1'
	s = [len(x) for x in s1.split('1')]
	i = 0
	for x in s:
		count = (x - k) // (1 + k)
		if count >= 0:
			i += count
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	l = []
	i = 0
	while i < len(s):
		x = s[i]
		if s[i] == '1':
			l.append(i)
		i = i + 1
	l = l[::-1]
	p = []
	i = 0
	cnt = 0
	while i < len(s):
		if len(l) != 0:
			if i == l[-1]:
				x = l.pop()
				p.append(x)
				i = i + 1
				continue
		if len(p) != 0 and len(l) != 0:
			d1 = l[-1] - i
			d2 = i - p[-1]
			if d1 > k and d2 > k:
				cnt = cnt + 1
				p.append(i)
		elif len(l) == 0 and len(p) != 0:
			d = i - p[-1]
			if d > k:
				cnt = cnt + 1
				p.append(i)
		elif len(l) == 0 and len(p) == 0:
			cnt = cnt + 1
			p.append(i)
		elif len(p) == 0:
			d = l[-1] - i
			if d > k:
				cnt = cnt + 1
				p.append(i)
		i = i + 1
	print(cnt)


import sys

def swap(x, y, a):
	temp = a[x]
	a[x] = a[y]
	a[y] = temp
	return a

def solve():
	return None

def main():
	q = []
	for line in sys.stdin.readlines():
		q.append(line)
	for i in range(len(q)):
		if i % 2 == 1:
			q[i] = q[i].rstrip().split(' ')
			q[i] = [int(x) for x in q[i]]
		else:
			q[i] = q[i].rstrip()
	for i in range(1, len(q), 2):
		d = q[i][1] + 1
		s = q[i + 1]
		z = len(s)
		loc = [-1]
		for i in range(len(s)):
			if s[i] == '1':
				loc.append(i)
		if len(loc) == 1 and z == d - 1:
			print(1)
			continue
		loc.append(z)
		res = 0
		for i in range(1, len(loc)):
			if loc[i] == loc[i - 1]:
				continue
			elif loc[i - 1] == -1 and loc[i] == z:
				res += 1
				res += (loc[i] - loc[i - 1] - 1 - 1) // d
			elif loc[i - 1] != -1 and loc[i] != z:
				temp = loc[i] - loc[i - 1] - 1
				if temp > 2 * (d - 1):
					temp -= d - 1
					res = res + temp // d
			else:
				res = res + (loc[i] - loc[i - 1] - 1) // d
		print(res)
main()


def solve():
	from math import ceil
	for _ in range(int(input())):
		(n, k) = map(int, input().strip().split())
		s = list(input())
		if n == 1:
			if s[0] == '1':
				print(0)
			else:
				print(1)
		elif s.count('1') == 0:
			if n == 1 or n <= k + 1:
				print(1)
				continue
			else:
				print(ceil(n / (k + 1)))
		else:
			l = []
			c = 0
			for i in range(n):
				if s[i] == '1':
					l.append(i)
					c += 1
			cf = 0
			for i in range(len(l)):
				if i == 0:
					cf += l[i] // (k + 1)
				else:
					d = l[i] - l[i - 1] - 1
					q = d // (k + 1)
					x = d % (k + 1)
					if x < k:
						cf += q - 1
					else:
						cf += q
			d = n - 1 - l[-1]
			cf += d // (k + 1)
			print(cf)
solve()


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		s = input()
		num = 0
		prev = -1
		for i in range(n):
			if s[i] == '1':
				numEmpty = i - prev - 1
				if prev > -1:
					numEmpty -= k
				num += max(0, numEmpty // (k + 1))
				prev = i
		if prev == -1:
			num += 1
			prev = 0
		num += max(0, (n - prev - 1) // (k + 1))
		print(num)
main()


t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = input()
	stol = 0
	c0 = 0
	for i in range(n):
		if a[i] == '0':
			c0 += 1
		else:
			if c0 == i:
				stol += c0 // (k + 1)
			else:
				stol += max(0, c0 - k) // (k + 1)
			c0 = 0
	if c0 > 0:
		if c0 == n:
			stol += (c0 + k) // (k + 1)
		else:
			stol += c0 // (k + 1)
	if c0 == n and n <= k:
		print(1)
	else:
		print(stol)


import math
a = int(input())
for i in range(a):
	n = [int(x) for x in input().split()]
	b = input()
	end = 0
	now = 0
	summ = 0
	while now < n[0] and end < n[0]:
		if b[now] != '0':
			now = now + 1
		else:
			end = now
			while end < n[0] and b[end] == '0':
				end = end + 1
			gap = end - now
			if now - 1 >= 0 and b[now - 1] == '1':
				gap -= n[1]
			if end < n[0] and b[end] == '1':
				gap -= n[1]
			summ += max(0, 1 + (gap - 1) // (n[1] + 1))
			now = end
		if end >= n[0] - 1 or now >= n[0]:
			break
	print(summ)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	arr = [0] * (n + 1)
	arr[n] = int(1000000000.0)
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			arr[i] = i
		else:
			arr[i] = arr[i + 1]
	lst = -1
	cnt = 0
	for i in range(n):
		ok = True
		if s[i] == '1':
			lst = i
		else:
			if lst != -1:
				if lst + k >= i:
					ok = False
			if arr[i] - k <= i:
				ok = False
			if ok:
				s[i] = '1'
				lst = i
				cnt += 1
	print(cnt)


import math
t = int(input())
for i in range(0, t):
	(n, k) = str(input()).split(' ')
	n = int(n)
	k = int(k)
	s = str(input())
	zero_only = True
	for i in range(0, len(s)):
		if s[i] == '1':
			zero_only = False
			break
	if zero_only:
		print(math.ceil(n / (k + 1)))
	else:
		ans = 0
		prev = -1
		res_prev = 0
		i = 0
		for i in range(0, len(s)):
			if s[i] == '1':
				res_prev = i
				break
		while i > 0:
			i -= k + 1
			if i > prev:
				ans += 1
			else:
				break
		prev = res_prev
		for i in range(prev + k, len(s)):
			if s[i] == '1':
				tmp = i
				while tmp > 0:
					tmp -= k + 1
					if tmp - k > prev:
						ans += 1
					else:
						break
				prev = i
		while prev < len(s) and prev != -1:
			prev += k + 1
			if prev < len(s):
				ans += 1
			else:
				break
		print(ans)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	last = 1 << 30
	ans = 0
	d = [0] * n
	for i in range(n - 1, -1, -1):
		if s[i] == '0':
			d[i] = 1 << 30 if i == n - 1 else 1 + d[i + 1]
	for i in range(n):
		last += 1
		if s[i] == '1':
			last = 0
		elif min(last, d[i]) > k:
			ans += 1
			last = 0
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	table = input()
	prev = float('-inf')
	ans = 0
	for (i, t) in enumerate(table):
		if t == '0' and i - prev > k:
			ans += 1
			prev = i
		if t == '1':
			if i - prev <= k:
				ans -= 1
			prev = i
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

def main():
	for _ in range(N()):
		(n, k) = RL()
		s = list(input())
		res = 0
		pre = k
		lst = -1
		for i in range(n):
			if pre == k and s[i] == '0':
				lst = i
				res += 1
				pre = 0
				continue
			if s[i] == '0':
				pre += 1
			else:
				if lst != -1 and i - k <= lst:
					res -= 1
				lst = -1
				pre = 0
		print(res)
main()


for _ in range(int(input())):
	(n, k) = map(int, input('').split())
	s = input('')
	i = 0
	x = k
	ans = 0
	while i < n:
		x = k
		if s[i] == '1':
			i = i + k + 1
			continue
		j = i + 1
		while j < n and x != 0:
			if s[j] == '1':
				break
			else:
				x -= 1
				j += 1
		if x == 0 or j == n:
			x = k
			ans += 1
		i = j
	print(ans)


from bisect import bisect_right, bisect_left, insort
inf = 10 ** 6
tests = int(input())
for _ in range(tests):
	(n, k) = map(int, input().split())
	s = input()
	ones = []
	for i in range(len(s)):
		if s[i] == '1':
			ones.append(i)
	onesr = list(reversed(ones))
	ans = 0
	for i in range(len(s)):
		if s[i] == '0':
			right = bisect_right(ones, i)
			left = -1
			if right == 0:
				left = -inf
			else:
				left = ones[right - 1]
			if right == len(ones):
				right = inf
			else:
				right = ones[right]
			if i - left > k and right - i > k:
				insort(ones, i)
				ans += 1
	print(ans)


def make(s, i, k):
	for j in range(-k, k + 1):
		if i + j < len(s) and i + j >= 0:
			s[i + j] = '2'
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	for i in range(n):
		if s[i] == '1':
			make(s, i, k)
	ans = 0
	i = 0
	while i < n:
		if s[i] == '0':
			j = max(-k, -i)
			count = 0
			while i + j < n and j < k + 1:
				if s[i + j] == '1':
					count += 1
					break
				j += 1
			if count == 0:
				ans += 1
				q = max(i - k, 0)
				r = min(i + k, n - 1)
				for p in range(q, r + 1):
					s[p] = '2'
		i += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lst = list(input())
	count = 0
	i = 0
	dist = 0
	if '1' not in lst:
		while i < n:
			i += k + 1
			count += 1
	else:
		while lst[i] != '1':
			i += 1
			dist += 1
		count += int(dist / (k + 1))
		dist = 0
		while i < n:
			if lst[i] == '0':
				dist += 1
			else:
				if dist >= 2 * k + 1:
					dist -= 2 * k + 1
					count += 1
					count += int(dist / (k + 1))
				dist = 0
			i += 1
	count += int(dist / (k + 1))
	print(count)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	one_pos = -1
	k += 1
	for i in range(n):
		if s[i] == '1':
			if one_pos != -1:
				if i - one_pos < k:
					count -= 1
			one_pos = i
		elif one_pos != -1:
			if i - one_pos >= k:
				one_pos = i
				count += 1
		else:
			one_pos = i
			count += 1
	print(count)


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)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = '0' * k + input() + '0' * k
	a = [int(len(i)) for i in s.split('1')]
	c = 0
	for x in a:
		c += (x - k) // (k + 1)
	print(c)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	s = '1' + k * '0' + s + k * '0' + '1'
	s2 = s.split('1')
	for i in s2[1:-1]:
		ans += (len(i) - 2 * k + k) // (k + 1)
	print(ans)


import math
t = int(input())
for j in range(t):
	(n, k) = map(int, input().split())
	s = input()
	(c, ans) = (0, 0)
	(start, f) = (0, 0)
	for i in s:
		if i == '0':
			c += 1
		else:
			f = 1
			if start == 0:
				ans += c // (k + 1)
				start = 1
			else:
				c = c - 2 * k
				ans += math.ceil(c / (k + 1))
			c = 0
	if c > 0:
		ans += c // (k + 1)
		if f == 0:
			print(max(1, math.ceil(c / (k + 1))))
		else:
			print(ans)
	else:
		print(ans)


test = int(input())
for t in range(test):
	(n, k) = map(int, input().split())
	string = input()
	count1 = 0
	ans = 0
	for x in range(n):
		if string[x] == '1':
			count1 = 0
		elif string[x] != '1':
			count1 += 1
			if count1 == k + 1 or x == 0:
				found = False
				for y in range(x + 1, min(x + k + 1, n)):
					if string[y] == '1':
						found = True
				if found == False:
					ans += 1
					count1 = 0
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, list(input())))
	ans = 0
	last1 = n * 2
	for i in range(n):
		if s[i] == 1:
			last1 = i
		elif abs(last1 - i) <= k:
			s[i] = 1
	last1 = n * 2
	for i in range(n - 1, -1, -1):
		if s[i] == 1:
			last1 = i
		elif abs(last1 - i) <= k:
			s[i] = 1
	i = 0
	while i < n:
		if s[i] == 0:
			ans += 1
			i += k + 1
		else:
			i += 1
	print(ans)


import math
for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	fst_one = -1
	for i in range(n):
		if s[i] == '1':
			fst_one = i
			break
	if fst_one == -1:
		print(math.ceil(n / (k + 1)))
	else:
		ones = []
		for i in range(n):
			if s[i] == '1':
				ones.append(i)
		ctr = 0
		for i in range(len(ones) - 1):
			diff = (ones[i + 1] - ones[i]) // (k + 1)
			if diff > 1:
				ctr += diff - 1
		if ones[0] > k:
			ctr += ones[0] // (k + 1)
		if n - 1 - ones[-1] > k:
			ctr += (n - 1 - ones[-1]) // (k + 1)
		print(ctr)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = input()
	if arr.count('1') == 0:
		print(1 + (n - 1) // (k + 1))
	else:
		cnt = 0
		ans = 0
		ones = []
		for i in range(n):
			if arr[i] == '1':
				ones.append(i)
		ans += ones[0] // (k + 1)
		ans += (n - 1 - ones[len(ones) - 1]) // (k + 1)
		for i in range(len(ones) - 1):
			ans += math.ceil((ones[i + 1] - (ones[i] + 1) - 2 * k) / (k + 1))
		print(ans)


from math import ceil, floor
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	b = []
	for i in range(n):
		if a[i] == '1':
			b.append(i)
	if len(b) == 0:
		print(ceil(n / (k + 1)))
	elif len(b) == 1:
		ans = floor(b[0] / (k + 1))
		ans += floor((n - 1 - b[0]) / (k + 1))
		print(ans)
	else:
		ans = 0
		for i in range(1, len(b)):
			x = b[i] - b[i - 1] - 1
			if x > 2 * k:
				x -= 2 * k
				ans += ceil(x / (k + 1))
		ans += floor(b[0] / (k + 1))
		ans += floor((n - 1 - b[-1]) / (k + 1))
		print(ans)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
t = int(input())
for test in range(t):
	(n, k) = get_ints()
	arr = get_string()
	iarr = []
	for i in range(n):
		if arr[i] == '1':
			iarr.append(i)
	if len(iarr) == 0 and arr.count('0') == n:
		print((n + k) // (k + 1))
		continue
	ans = 0
	for i in range(1, len(iarr)):
		temp = max(0, iarr[i] - iarr[i - 1] - 1)
		temp -= 2 * k
		temp = max(0, temp)
		ans += (temp + k) // (k + 1)
	temp1 = iarr[0]
	temp1 -= k
	temp1 = max(0, temp1)
	ans += (temp1 + k) // (k + 1)
	temp1 = n - 1 - iarr[len(iarr) - 1]
	temp1 -= k
	temp1 = max(0, temp1)
	ans += (temp1 + k) // (k + 1)
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	a = [int(x) for x in s]
	z = 0
	res = 0
	check = 0
	val = 0
	for i in range(n):
		if a[i] == 0:
			z += 1
		else:
			if val == 0:
				res += z // (k + 1)
			else:
				res += (z - k) // (k + 1)
			val = 1
			z = 0
			check = 1
	if check == 0:
		res += max(1, z // (k + 1))
		if z - z // (k + 1) * (k + 1) != 0 and z // (k + 1) != 0:
			res += 1
	else:
		res += z // (k + 1)
	print(res)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input())[:-1]
	res = 0
	for i in range(n):
		if s[i] == '1':
			for j in range(i - k, i + k + 1):
				if j >= 0 and j < n:
					s[j] = '-1'
	for i in range(n):
		if s[i] == '0':
			res += 1
			for j in range(i, i + k + 1):
				if j >= 0 and j < n:
					s[j] = '-1'
	print(res)


from sys import stdin, stdout
from collections import deque, defaultdict
from math import ceil, floor, inf, sqrt, factorial, gcd, log2
from copy import deepcopy
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
for _ in range(ii1()):
	(n, k) = iia()
	arr = is1()
	count = 0
	ans = 0
	for i in range(n):
		if arr[i] == '0':
			count += 1
		elif count >= 1:
			if count - i == 0:
				ans += count // (k + 1)
			elif count - k > 0:
				ans += (count - k) // (k + 1)
			count = 0
	if count == n and k > n:
		ans = 1
	elif count == n and k <= n:
		if n / (k + 1) > n // (k + 1):
			ans = n // (k + 1) + 1
		else:
			ans = n // (k + 1)
	elif count >= 1 and count < n:
		ans += count // (k + 1)
	print(ans)


for xyz in range(0, int(input())):
	(n, k) = map(int, input().split())
	s = input()
	a = 0
	f1 = [-1 * k - 1]
	for i in range(0, n):
		if s[i] == '1':
			f1.append(i)
	f1.append(n + k)
	d = []
	for i in range(1, len(f1)):
		d.append(f1[i] - f1[i - 1] - 1)
	for i in d:
		a += max(0, (i - k) // (k + 1))
	print(a)


def readintlst():
	return list(map(int, input().split(' ')))

def readn():
	return int(input())
import math
for _ in range(readn()):
	(n, k) = readintlst()
	arr = list(map(int, list(input())))
	prev = -1
	ans = 0
	for (i, v) in enumerate(arr):
		if v == 1:
			gap = i - prev
			if prev == -1:
				ans += i // (k + 1)
			else:
				ans += max((gap - 1 - k) // (k + 1), 0)
			prev = i
	if prev == -1:
		ans += math.ceil(n / (k + 1))
	else:
		ans += (n - prev - 1) // (k + 1)
	print(ans)


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	s = input().strip()
	(ret, j) = (0, k)
	for i in range(n):
		j = j + 1 if s[i] == '0' else 0
		if j == 2 * k + 1 or (i == n - 1 and j > k):
			(ret, j) = (ret + 1, k)
	print(ret)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input()]
	last = 2 * k - 1
	cnt = 0
	ex = 0
	fin = 0
	for i in range(n):
		if a[i] == 1:
			ex = 1
			last = i
			break
	for i in range(n - 1, -1, -1):
		if a[i]:
			fin = i
			break
	if not ex:
		last = 0
		cnt = 1
		for i in range(1, n):
			if i - last > k:
				last = i
				cnt += 1
		print(cnt)
		continue
	cp = last
	for i in range(cp - 1, -1, -1):
		if cp - i > k:
			cnt += 1
			cp = i
	for i in range(last, fin):
		if a[i] == 0:
			if i - last > 2 * k:
				last = k + last + 1
				cnt += 1
		else:
			last = i
	for i in range(fin + 1, n):
		if i - fin > k:
			fin = i
			cnt += 1
	print(cnt)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input()))
	a1 = a.copy()
	a2 = a.copy()
	a3 = a.copy()
	c = 0
	for i in range(n):
		if a[i] == 1:
			c = k
		elif c:
			a1[i] = 1
			c -= 1
	c = 0
	for i in range(n - 1, -1, -1):
		if a[i] == 1:
			c = k
		elif c:
			a2[i] = 1
			c -= 1
	for i in range(n):
		a3[i] = min(1, a1[i] + a2[i])
	s = 0
	c = 0
	for i in range(n):
		if a3[i] == 0 and (not c):
			s += 1
			c = k + 1
		c = max(0, c - 1)
	print(s)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	mk = 0
	for i in range(n):
		if s[i] == '1':
			for j in range(max(mk, i - k), min(i + k + 1, n)):
				s[j] = 'X'
			mk = j
	ans = 0
	newBoundary = -1
	for i in range(n):
		if i > newBoundary and s[i] == '0':
			ans += 1
			newBoundary = i + k
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(str, input()))
	m = 0
	for i in range(n):
		if s[i] == '1':
			for j in range(i - k, i + k + 1):
				if j > -1 and j < n:
					s[j] = 'z'
	p = 0
	count = 0
	while p < n:
		if s[p] == '0':
			p += k + 1
			count += 1
		else:
			p += 1
	print(count)


import math

def solve(n, k, s):
	p = -1
	res = 0
	if '1' not in s:
		return math.ceil(n / (k + 1))
	for i in range(n):
		if s[i] == '1':
			if p == -1:
				res += int(i / (k + 1))
			else:
				res += math.ceil((i - p - 1 - 2 * k) / (k + 1))
			p = i
	res += int((n - p - 1) / (k + 1))
	return int(res)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	print(solve(n, k, s))


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	s = input()
	s = s.split('1')
	tables = 0
	if len(s) == 1:
		tables += (len(s[0]) + k) // (k + 1)
	else:
		tables += len(s[0]) // (k + 1)
		tables += len(s[-1]) // (k + 1)
		for j in range(1, len(s[:-1])):
			if len(s[j]) != 0:
				tables += (len(s[j]) - k) // (k + 1)
	print(tables)


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(councils, a, k):
	summ = 0
	for x in a:
		summ += min(x, councils)
	return summ // councils >= k
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	(n, k) = read()
	bs = input().rstrip()
	binaryString = list(bs)
	ans = 0
	i = 0
	while i < n:
		j = i + 1
		while j < n:
			if bs[j] == '1':
				break
			j += 1
		if bs[i] == '1':
			left = k
		else:
			left = 0
		if j < n and bs[j] == '1':
			right = k
		else:
			right = 0
		length = j - i
		if left == k:
			length -= 1
		length -= left + right
		if length > 0:
			ans += (length + k) // (k + 1)
		i = j
	print(ans)
for _ in range(int(input())):
	solve()


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


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = ['2'] + [i for i in input()] + ['2']
	(d, l, r) = ([], 0, 0)
	cnt = 0
	while r <= n + 1:
		if s[r] != '0':
			if s[r] == '1':
				d.append(s[l:r])
				r += 1
				l = r
			else:
				d.append(s[l:r + 1])
				l = r
				r += 1
		else:
			r += 1
	for i in d:
		if len(i) > 1:
			if i[0] == '2' and i[-1] == '2':
				for j in range(1, len(i) - 1, k + 1):
					cnt += 1
			elif i[0] == '2' or i[-1] == '2':
				for j in range(k + 1, len(i), k + 1):
					cnt += 1
			else:
				for j in range(k + 1, len(i) - k + 1, k + 1):
					cnt += 1
	print(cnt)


n = int(input())
for _ in range(n):
	(t, k) = map(int, input().split())
	a = input()
	c = 0
	ind = 0
	d = 0
	while ind < t:
		f = True
		if a[ind] == '0':
			for j in range(ind + 1, ind + k + 1):
				if j < t:
					if a[j] == '1':
						f = False
						d = j
			if f:
				c += 1
		if f == False:
			ind = d + k + 1
		else:
			ind = ind + k + 1
	print(c)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	(n, k) = rl()
	s = input()
	blocks = [len(b) for b in s.split('1')]
	if len(blocks) == 1:
		print((blocks[0] + k) // (k + 1))
		return
	else:
		total = blocks[0] // (k + 1) + blocks[-1] // (k + 1)
		for b in blocks[1:-1]:
			total += max(0, (b - k) // (k + 1))
	print(total)
mode = 'T'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	s = [int(i) for i in input()]
	(i, prev, ans) = (0, 0, 0)
	while i < n:
		if s[i] == 1:
			i = i + k + 1
		else:
			count = 1
			while count <= k and i + count < n:
				if s[i + count] != 1:
					count += 1
				else:
					break
			if count == k + 1:
				s[i] = 1
				ans += 1
				i = i + k + 1
			elif i + count == n:
				s[i] = 1
				ans += 1
			else:
				i = i + k + count + 1
	print(ans)


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	a = []
	for i in range(n):
		if s[i] == '1':
			a.append(i)
	ans = 0
	if len(a):
		if a[0] - k > 0:
			ans += ceil((a[0] - k) / (k + 1))
		for i in range(0, len(a) - 1):
			ans += (a[i + 1] - a[i] - 1 - k) // (k + 1)
		if n - 1 - a[-1] - k > 0:
			ans += ceil((n - 1 - a[-1] - k) / (k + 1))
	else:
		ans = ceil(n / (k + 1))
	print(ans)


t = int(input())
for _ in range(t):
	n = list(map(int, input().split()))
	s = list(input())
	num = 0
	flag = True
	ans = 0
	for i in range(0, n[0]):
		if s[i] == '0':
			num += 1
		else:
			if flag and num >= n[1] + 1:
				ans += num // (n[1] + 1)
			elif num >= 2 * n[1] + 1:
				ans += (num - n[1]) // (n[1] + 1)
			flag = False
			num = 0
	if num == len(s) and num < n[1] + 1:
		print('1')
	elif num == len(s) and num > num // (n[1] + 1) * (n[1] + 1):
		print(num // (n[1] + 1) + 1)
	else:
		ans += num // (n[1] + 1)
		print(ans)


N = int(input())
for i in range(N):
	(n, k) = tuple(map(int, input().split()))
	s = input()
	if len(s) == 1:
		if s == '0':
			print(1)
		else:
			print(0)
		continue
	l = 0
	ret = 0
	first = True
	for x in s:
		if x == '0':
			l += 1
		else:
			if first is True:
				ret += l // (k + 1)
				first = False
			else:
				ret += max(0, (l - k) // (k + 1))
			l = 0
	if l == len(s):
		ret = (l + k) // (k + 1)
	else:
		ret += l // (k + 1)
	print(ret)


from collections import *
from bisect import *
from math import *
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(input())
	ans = 0
	val = k
	for i in range(n):
		if l[i] == '1':
			if val < k:
				ans -= 1
			val = 0
		else:
			val += 1
			if val == k + 1:
				ans += 1
				val = 0
	print(ans)


import sys

def answer(n, k, s):
	num_zeros = k
	cnt = 0
	for i in range(n):
		if s[i] == '0':
			num_zeros += 1
			if num_zeros >= 2 * k + 1:
				cnt += 1
				num_zeros = k
		else:
			num_zeros = 0
	num_zeros += k
	if num_zeros >= 2 * k + 1:
		cnt += 1
	return cnt

def main():
	t = int(input())
	while t:
		(n, k) = [int(i) for i in sys.stdin.readline().split()]
		s = sys.stdin.readline().rstrip()
		print(answer(n, k, s))
		t -= 1
	return
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	og = list(input())
	nw = og[:]
	for i in range(n):
		if og[i] == '1':
			for j in range(0, k + 1):
				nw[max(0, i - j)] = '1'
				nw[min(n - 1, i + j)] = '1'
	s = ''.join([x for x in nw]).split('1')
	s = [x for x in s if x != '']
	ans = 0
	for x in s:
		ans += 1 + (len(x) - 1) // (k + 1)
	print(ans)


from sys import stdin

def ip():
	return [int(i) for i in stdin.readline().split()]

def sp():
	return [str(i) for i in stdin.readline().split()]

def solve():
	(n, k) = ip()
	A = list(str(input()))
	for i in range(n):
		if A[i] == '1':
			for x in range(i - 1, i - k - 1, -1):
				if x < 0 or A[x] == 'x':
					break
				A[x] = 'x'
			for y in range(i + 1, i + k + 1):
				if y >= n or A[y] == 'x':
					break
				A[y] = 'x'
	ans = 0
	for i in range(n):
		if A[i] == '0':
			A[i] = '1'
			ans += 1
			for x in range(i - 1, i - k - 1, -1):
				if x < 0 or A[x] == 'x':
					break
				A[x] = 'x'
			for y in range(i + 1, i + k + 1):
				if y >= n or A[y] == 'x':
					break
				A[y] = 'x'
	return ans
t = int(input())
for _ in range(t):
	print(solve())


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	s = input()
	pos = k
	res = 0
	for i in range(len(s)):
		if s[i] == '1':
			res += pos // (k + 1)
			if pos % (k + 1) < k:
				res -= 1
			pos = 0
		else:
			pos += 1
	res += pos // (k + 1)
	print(res)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ans = 0
	s = input()
	last_one = -1
	for j in range(len(s)):
		if s[j] == '1':
			if last_one == -1:
				ans = ans + max(0, j // (k + 1))
			else:
				ans = ans + max(0, (j - last_one - k - 1) // (k + 1))
			last_one = j
	if last_one == -1:
		ans = ans + max(1, 1 + (n - 1) // (k + 1))
	else:
		ans = ans + max(0, (n - last_one - 1) // (k + 1))
	print(ans)


t = int(input())

def givezero(s):
	ans = []
	k = n
	for ss in range(len(s)):
		if s[ss] == '0':
			k += 1
			ans.append(k)
		else:
			k = 0
			ans.append(k)
	return ans
for i in range(t):
	(n, k) = [int(x) for x in input().split(' ')]
	s = input()
	f_a = givezero(s)
	f_b = givezero(s[::-1])
	f_b = f_b[::-1]
	ans = 0
	j = 0
	while j < len(f_a):
		if f_a[j] > k and f_b[j] > k:
			ans += 1
			j += k
		j += 1
	print(ans)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	prev1 = 0
	cnt = 0
	if len(s) > 2:
		for i in range(len(s)):
			if i != 0 and i != len(s) - 1:
				if s[i] == '0' and prev1 + 2 * m + 1 <= i:
					cnt += 1
					prev1 += m + 1
				elif s[i] == '1':
					prev1 = i
			elif i == 0 and s[i] == '0':
				t1 = 0
				for j in range(1, min(m + 1, len(s))):
					if s[i + j] == '1':
						t1 = 1
						break
				if t1 == 0:
					cnt += 1
					prev1 = 0
			elif i == len(s) - 1 and s[len(s) - 1] == '0':
				t1 = 0
				for j in range(1, min(m + 1, len(s))):
					if s[i - j] == '1':
						t1 = 1
						break
				if t1 == 0 and i - prev1 > m:
					cnt += 1
		print(cnt)
	elif s.count('1') == 0:
		print(1)
	else:
		print(0)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	a = 0
	max = 0
	i = 0
	while i < n:
		if s[i] == '0':
			j = i + 1
			while j <= i + k and j < n:
				if s[j] == '1':
					max = 1
					i = j
					break
				j += 1
			if max == 1:
				max = 0
			else:
				i += k + 1
				a += 1
		elif s[i] == '1':
			i += k + 1
	print(a)


test = int(input())
for t in range(test):
	(n, k) = map(int, input().split())
	string = input()
	last = -k - 5
	ans = 0
	for x in range(n):
		if string[x] == '0':
			if x - last > k:
				ans += 1
				last = x
		else:
			if x - last <= k:
				ans -= 1
			last = x
	print(ans)


test = int(input())
for t in range(test):
	(n, k) = map(int, input().split())
	s = input()
	arr = list(s)
	array1 = arr.copy()
	negative = 0 - k
	ans = []
	ans.append(-1)
	ans1 = []
	if '1' in arr:
		c = 0
		for i in range(n):
			if arr[i] == '1':
				ans.append(i)
		ans.append(n)
		for i in range(1, len(ans)):
			ans1.append(ans[i] - ans[i - 1] - 1)
		ans1[0] -= k
		ans1[len(ans1) - 1] -= k
		for i in range(1, len(ans1) - 1):
			ans1[i] -= 2 * k
		for i in range(len(ans1)):
			for j in range(0, ans1[i], k + 1):
				c += 1
				array1[i] = '1'
	else:
		c = 0
		for i in range(0, len(arr), k + 1):
			c += 1
			array1[i] = '1'
			ans.append(i)
	print(c)


t = int(input())
for case in range(t):
	(n, k) = map(int, input().split())
	s = [int(i) for i in input()]
	su = sum(s[:k])
	tables = 0
	for i in range(n):
		if i + k < n:
			su += s[i + k]
		if i - k - 1 >= 0:
			su -= s[i - k - 1]
		if su == 0:
			tables += 1
			su += 1
			s[i] = 1
	print(tables)


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	c = 0
	if s[0] == '0':
		c += 1
	start = 0
	for j in range(1, n):
		if s[j] == '1':
			if j - start - 1 < k:
				c -= 1
			start = j
		elif j - start - 1 == k:
			c += 1
			start = j
	print(c)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	i = 0
	while i < n:
		if s[i] == '0':
			j = i + 1
			while j < n:
				if s[j] == '0':
					j += 1
				else:
					break
			if i == 0 and j == n:
				temp = max(0, j - i)
			elif i == 0 and j != n:
				temp = max(0, j - i - k)
			elif i != 0 and j == n:
				temp = max(0, j - i - k)
			else:
				temp = max(0, j - i - 2 * k)
			if temp != 0:
				ans += 1
				temp -= 1
				ans += temp // (k + 1)
			i = j
		else:
			i += 1
	print(ans)


from collections import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	(n, k) = rl()
	s = input()
	l = len(s)
	ans = 0
	a = []
	for i in range(l):
		if s[i] == '1':
			a.append(i)
	if len(a) == 0:
		ans = 1 + (l - 1) // (k + 1)
	elif len(a) == 1:
		ans = a[0] // (k + 1) + (l - 1 - a[0]) // (k + 1)
	else:
		ans = a[0] // (k + 1) + (l - 1 - a[-1]) // (k + 1)
		for i in range(len(a) - 1):
			small = a[i]
			big = a[i + 1]
			if big - small - 1 >= k:
				ans += (big - small - 1 - k) // (k + 1)
	print(ans)


from sys import stdin
import math
from bisect import bisect_right
from bisect import bisect_left

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, k) = [int(x) for x in inp().split()]
	s = inp()
	flag = False
	ans = 0
	counter = 0
	zeroes = 0
	for i in range(n):
		if s[i] == '1':
			flag = True
			zeroes -= k
			ans += math.ceil(zeroes / (k + 1))
			counter = 0
			zeroes = 0
		elif s[i] == '0':
			counter += 1
			if flag and counter > k:
				zeroes += 1
			elif not flag:
				zeroes += 1
	ans += math.ceil(zeroes / (k + 1))
	print(ans)


def getint():
	return int(input())

def getint2():
	return map(int, input().split())

def getintlist():
	return map(int, input().split())

def getstring():
	return input()
cas = getint()
while cas > 0:
	(n, k) = getint2()
	s = getstring()
	cnt = 0
	ara = [0] * (n + 5)
	for i in range(n):
		if s[i] == '1':
			fi = max(0, i - k)
			la = min(n - 1, i + k)
			ara[fi] += 1
			ara[la + 1] -= 1
	for i in range(1, n):
		ara[i] += ara[i - 1]
	prv = 0
	ans = 0
	for i in range(n):
		if ara[i] != 0:
			res = prv // (k + 1) + (1 if prv % (k + 1) != 0 else 0)
			ans += res
			prv = 0
		else:
			prv = prv + 1
	ans += prv // (k + 1) + (1 if prv % (k + 1) != 0 else 0)
	print(ans)
	cas = cas - 1


import math
from sys import stdin
from collections import Counter, defaultdict, deque
input = stdin.readline
mod = pow(10, 9) + 7

def solve():
	(n, k) = map(int, input().split())
	count = 0
	s = list(input().strip())
	c = 0
	for i in range(n):
		if s[i] != '1' and c == 0:
			count += 1
			c = k + 1
		elif s[i] == '1' and c != 0:
			count -= 1
			c = k + 1
		elif s[i] == '1':
			c = k + 1
		c = c - 1
	print(count)
for _ in range(int(input())):
	solve()


t = int(input())
m = 1
while m <= t:
	(n, k) = map(int, input().split())
	s = input()
	p = list(s)
	i = 0
	j = 0
	while i < len(p):
		if p[i] == '1':
			j = i - 1
			while j >= max(0, i - k):
				p[j] = '1'
				j -= 1
			j = i + 1
			while j <= min(n - 1, i + k):
				p[j] = '1'
				j += 1
			i = j - 1
		i += 1
	i = 0
	ans = 0
	while i < len(p):
		if p[i] == '0':
			ans += 1
			p[i] = '1'
			j = i + 1
			while j <= min(n - 1, i + k):
				p[j] = '1'
				j += 1
			i = j - 1
		i += 1
	print(ans)
	m += 1


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	arr = input()
	i = 0
	while i < n and arr[i] == '0':
		i += 1
	if i == n:
		quant = (i - 1) // (k + 1) + 1
		print(quant)
		continue
	dist = 0
	contUm = 0
	quant = i // (k + 1)
	i += 1
	while i < n:
		if arr[i] == '0':
			dist += 1
		else:
			lastOne = i
			x = (dist + 1) // (k + 1) - 1
			if x > 0:
				quant += x
			dist = 0
			contUm += 1
		i += 1
	quant += dist // (k + 1)
	print(quant)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	a = 0
	for i in range(n):
		if s[i] == '1':
			a = i
			break
	r = a // (k + 1)
	while (r + 1) * (k + 1) <= a:
		r += 1
	ans = r
	counter = 0
	flag = 0
	for i in range(a, n):
		if s[i] == '0':
			counter += 1
		else:
			r = (counter + 1) // (k + 1)
			flag = 1
			while (r + 1) * (k + 1) <= counter + 1:
				r += 1
			ans += max(0, r - 1)
			counter = 0
	r = counter // (k + 1)
	while (r + 1) * (k + 1) <= counter:
		r += 1
	ans += r
	if flag == 0:
		r = (n - 1) // (k + 1)
		while (r + 1) * (k + 1) <= n - 1:
			r += 1
		print(r + 1)
	else:
		print(ans)


n = int(input())
for i in range(n):
	re = 0
	ch = 0
	no = 0
	(n1, k) = map(int, input().split())
	s = input()
	s = '1' + '0' * k + s + '0' * k + '1'
	for i in range(n1 + 2 * k + 2):
		if s[i] == '1':
			if s[i - 1] == '0':
				ch = max(0, ch - k)
				re += ch // (k + 1)
				ch = 0
		else:
			ch += 1
	print(re)


T = int(input())

def main():
	(n, k) = list(map(int, input().split()))
	s = str(input())
	occupied = [0] * n
	for i in range(n):
		if s[i] == '1':
			occupied[max(0, i - k):i + k + 1] = [1] * len(occupied[max(0, i - k):i + k + 1])
		else:
			continue
	p1 = 0
	c = 0
	while p1 < n:
		if occupied[p1] != 1:
			c = c + 1
			p1 = p1 + k + 1
		else:
			p1 = p1 + 1
	return c
for i in range(T):
	print(main())


test = int(input())
from math import ceil
while test != 0:
	test -= 1
	(n, k) = map(int, input().split())
	s = input()
	gi = []
	for i in range(n):
		if s[i] == '1':
			gi.append(i)
	ind = 0
	ans = 0
	for i in gi:
		nu = max(0, i - k - ind)
		ans += ceil(nu / (k + 1))
		ind = i + k + 1
	nu = max(0, n - ind)
	ans += ceil(nu / (k + 1))
	print(ans)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if s.count('0') == len(s):
		print(math.ceil(len(s) / (k + 1)))
	else:
		anz = 0
		st = s.index('1')
		en = n - s[::-1].index('1')
		if st > 0:
			anz += math.ceil((st - k) / (k + 1))
		if n - en > 0:
			anz += math.ceil((n - en - k) / (k + 1))
		i = st + 1
		while i < en:
			j = i
			while j < en and s[j] != '1':
				j += 1
			if j - i - 2 * k > 0:
				anz += math.ceil((j - i - 2 * k) / (k + 1))
			i = j + 1
		print(anz)


t = int(input())
while t > 0:
	(n, k) = list(map(int, input().split(' ')))
	s = input()
	curr_zero = 0
	found_one = False
	ans = 0
	for c in s:
		if not found_one and c == '1':
			ans += curr_zero // (k + 1)
			found_one = True
			curr_zero = 0
		elif found_one and c == '1':
			ans += max(curr_zero - k, 0) // (k + 1)
			curr_zero = 0
		else:
			curr_zero += 1
	ans += max(curr_zero, 0) // (k + 1)
	if not found_one:
		ans = -(-len(s) // (k + 1))
	t -= 1
	print(ans)


import math
t = int(input())
for row in range(t):
	(n, k) = [int(i) for i in input().split()]
	line = input()
	i = 0
	count = 0
	step = 0
	first_time = 0
	check_last = 2000001
	if line[0] == '1':
		checker = 1
	else:
		checker = 0
	jopa = 0
	while i != len(line):
		if line[i] == '0':
			step += 1
			jopa += 1
		else:
			first_time += 1
			if checker == 1 or first_time == 1:
				count += math.ceil((step - k) / (k + 1))
				step = 0
				checker = 0
			else:
				count += math.ceil((step - 2 * k) / (k + 1))
				step = 0
		i += 1
	if checker == 1:
		count += math.ceil((step - k) / (k + 1))
	elif jopa == len(line):
		count += math.ceil(step / (k + 1))
	else:
		count += math.ceil((step - k) / (k + 1))
	print(count)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inin():
	return int(input())

def inar():
	return list(map(int, input().split()))

class FenwickTree:

	def __init__(self, x):
		self.bit = x
		for i in range(len(x)):
			j = i | i + 1
			if j < len(x):
				x[j] += x[i]

	def update(self, idx, x):
		while idx < len(self.bit):
			self.bit[idx] += x
			idx |= idx + 1

	def query(self, end):
		x = 0
		while end:
			x += self.bit[end - 1]
			end &= end - 1
		return x
Testcase = inin()
for _ in range(Testcase):
	(n, k) = inar()
	s = input()
	tree = []
	for i in s:
		if i == '1':
			tree.append(1)
		else:
			tree.append(0)
	tree = FenwickTree(tree)
	j = 0
	for i in range(n):
		if s[i] == '1':
			break
		j += 1
	else:
		j = 0
	ans = 0
	i = 0
	while i < n:
		if s[i] == '1':
			i += 1
			continue
		li = max(0, i - k)
		ri = min(n, i + k + 1)
		if tree.query(ri) - tree.query(li) == 0 and s[i] == '0':
			ans += 1
			tree.update(i, 1)
		i += 1
	print(ans)


import math
t = int(input())
for _ in range(0, t):
	(n, k) = [int(i) for i in input().split()]
	s = input()
	res = 0
	i = 0
	while i < n:
		j = i + 1
		while j < n and s[j] != '1':
			j += 1
		left = k if s[i] == '1' else 0
		right = k if j < n and s[j] == '1' else 0
		l = j - i
		if left == k:
			l -= 1
		l -= left + right
		if l > 0:
			res += (l + k) // (k + 1)
		i = j
	print(res)


import math
q = int(input())
for _ in range(q):
	(n, k) = list(map(int, input().split()))
	a = list(input())
	i = 0
	res = 0
	while i < n and a[i] == '0':
		i += 1
	if i == n:
		res = math.ceil(n / (k + 1))
	else:
		x = i - k
		if x > 0:
			res = math.ceil(x / (k + 1))
		c = i
		i += 1
		while i < n:
			if a[i] == '1':
				x = i - 1 - c - k - k
				if x > 0:
					res += math.ceil(x / (k + 1))
				c = i
			i += 1
		x = n - 1 - c - k
		if x > 0:
			res += math.ceil(x / (k + 1))
	print(res)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(input())
	index = -1
	b = [-1 for i in range(n)]
	for i in range(n - 1, -1, -1):
		b[i] = index
		if a[i] == '1':
			index = i
	ans = 0
	i = 0
	while i < n:
		if a[i] == '1':
			i += k + 1
			continue
		elif a[i] == '0' and b[i] == -1:
			ans += 1
			i += k + 1
		elif a[i] == '0' and b[i] - i > k:
			ans += 1
			i += k + 1
		else:
			i += 1
	print(ans)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split(' '))
	s = input()
	ones = list(filter(lambda x: s[x] == '1', range(n)))
	ones.insert(0, -k - 1)
	ones.append(n + k)
	l = len(ones)
	ans = 0
	for i in range(l - 1):
		ans += (ones[i + 1] - ones[i] - k - 1) // (k + 1)
	print(ans)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	q = input()
	q = '0' * y + q + '0' * y
	mylist = q.split('1')
	sum = 0
	for val in mylist:
		sum += (len(val) - y) // (y + 1)
	print(sum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(input())
	cnt = 0
	ans = 1
	for i in range(n):
		if arr[i] == '1':
			if cnt <= k:
				ans -= 1
			cnt = 0
		elif cnt > k:
			ans += 1
			cnt = 0
		cnt += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	pre = -1
	left = [-(k + 1)] * n
	right = [float('inf')] * n
	if s[0] == '1':
		left[0] = 0
	if s[n - 1] == '1':
		right[n - 1] = n - 1
	for x in range(n - 2, -1, -1):
		if s[x] == '1':
			right[x] = x
		else:
			right[x] = right[x + 1]
	ans = 0
	for val in range(n):
		if s[val] == '0' and val - k > left[val] and (val + k < right[val]):
			ans += 1
			left[val] = val
		if val + 1 < n:
			if s[val + 1] == '1':
				left[val + 1] = val + 1
			else:
				left[val + 1] = max(left[val], left[val + 1])
	print(ans)


t = int(input())
for tt in range(0, t):
	(n, k) = map(int, input().split())
	s = input()
	if s[0] == '1':
		a = 0
	else:
		a = -1
	b = -1
	d = 0
	for i in range(0, n):
		if s[i] == '1':
			b = i
			if a == -1:
				c = b - k
				c = 1 + (c - 1) // (k + 1)
				d = d + c
				a = b
			else:
				c = b - a - 1
				if c > 2 * k:
					c = c - 2 * k
					c = 1 + (c - 1) // (k + 1)
					d = d + c
				a = b
	e = n - b - k - 1
	e = 1 + (e - 1) // (k + 1)
	if e > 0:
		d = d + e
	if b == -1:
		if n <= k + 1:
			print(1)
		else:
			print((n - 1) // (k + 1) + 1)
	else:
		print(d)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	if '1' in s:
		lsta = []
		for j in range(n):
			if s[j] == '1':
				lsta.append(j)
		c = 0
		dif1 = lsta[0] - k
		if dif1 > 0:
			c += 1
			ind = 0
			while True:
				if ind > dif1 - 1:
					break
				else:
					ind += k + 1
					if ind < dif1:
						c += 1
		dif2 = n - 1 - lsta[-1] - k
		if dif2 > 0:
			c += 1
			ind = 0
			while True:
				if ind > dif2 - 1:
					break
				else:
					ind += k + 1
					if ind < dif2:
						c += 1
		l = len(lsta)
		for h in range(1, l):
			dif = lsta[h] - lsta[h - 1] - 1 - 2 * k
			if dif > 0:
				c += 1
				ind = 0
				while True:
					if ind > dif - 1:
						break
					else:
						ind += k + 1
						if ind < dif:
							c += 1
	else:
		c = 1
		ind = 0
		while True:
			if ind > n - 1:
				break
			else:
				ind += k + 1
				if ind < n:
					c += 1
	print(c)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	f = True
	zero = 0
	ans = 0
	for c in s:
		if c == '0':
			zero += 1
		else:
			if f:
				f = False
				if zero >= k + 1:
					ans += 1
					zero = max(zero - k - 1, 0)
			else:
				zero = max(zero - k, 0)
			ans += zero // (k + 1)
			zero = 0
	if f and zero:
		ans += 1
		zero -= 1
	ans += zero // (k + 1)
	print(ans)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ind = []
	for i in range(n):
		if s[i] == '1':
			ind.append(i)
	if len(ind) == 0:
		ans = math.ceil(n / (k + 1))
	else:
		o1 = max(0, ind[0] - 0)
		o2 = max(0, n - 1 - ind[-1])
		t = []
		ans = math.ceil((o1 - k) / (k + 1)) + math.ceil((o2 - k) / (k + 1))
		if len(ind) >= 2:
			for i in range(1, len(ind)):
				t.append(ind[i] - ind[i - 1] - 1)
		for i in t:
			ans += max(0, math.ceil((i - 2 * k) / (k + 1)))
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = input()
	ans = 0
	i = 0
	while i < n:
		if a[i] == '1':
			break
		i += 1
	if i == n:
		ans += (i + k) // (k + 1)
	else:
		ans += i // (k + 1)
	c = 0
	x = i
	for i in range(x + 1, n):
		if a[i] == '1':
			ans += (c - k) // (k + 1)
			c = 0
		else:
			c += 1
	ans += c // (k + 1)
	print(ans)


t = int(input())
while t:
	t = t - 1
	(n, k) = map(int, input().split())
	a = list(input())
	b = [-1 for i in range(n)]
	ind = -1
	for i in range(n - 1, -1, -1):
		b[i] = ind
		if a[i] == '1':
			ind = i
	out = 0
	i = 0
	while i < n:
		if a[i] == '1':
			i += k + 1
			continue
		if a[i] == '0' and b[i] == -1:
			out += 1
			i += k + 1
		elif a[i] == '0' and b[i] - i > k:
			out += 1
			i += k + 1
		else:
			i = b[i]
	print(out)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s1 = '1' + '0' * k + input() + '0' * k + '1'
	s2 = [len(x) for x in s1.split('1')]
	cont = 0
	for i in s2:
		r = (i - k) // (1 + k)
		if r > 0:
			cont += r
	print(cont)


from math import *

def f():
	(n, k) = map(int, input().split(' '))
	a = input()
	c = 0
	s = 0
	j = 0
	while j < len(a):
		if a[j] == '1':
			break
		c += 1
		j += 1
	s += int(ceil((c - k) / (k + 1)))
	c = 0
	for i in range(j + 1, len(a)):
		if a[i] == '1':
			c -= 2 * k
			s += int(ceil(c / (k + 1)))
			c = 0
		else:
			c += 1
	s += int(ceil((c - k) / (k + 1)))
	if a.count('0') == len(a):
		s = int(ceil(len(a) / (k + 1)))
	print(s)
for i in range(int(input())):
	f()


from math import ceil

def check(table, occupied, i, k, n):
	lower = max(i - k, 0)
	greater = min(i + k, n - 1)
	for j in range(lower, greater + 1):
		table[j] = 1
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	t = input()
	table = [int(i) for i in t]
	occupied = []
	for i in range(n):
		if table[i] == 1:
			occupied.append(i)
	if len(occupied) == 0:
		ans = int(ceil(n / (k + 1)))
		print(ans)
	else:
		for i in occupied:
			lower = max(i - k, 0)
			greater = min(i + k, n - 1)
			for j in range(lower, greater + 1):
				table[j] = 1
		ans = 0
		for i in range(len(table)):
			if table[i] == 0:
				check(table, occupied, i, k, n)
				ans += 1
		print(ans)


def set_tables(arr):
	prev = -k - 1
	new_tables = 0
	for (i, table) in enumerate(arr):
		if table:
			if i < prev + k + 1:
				new_tables -= 1
			prev = i
		elif i == prev + k + 1:
			prev = i
			new_tables += 1
	return new_tables
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, list(input())))
	res = set_tables(arr)
	print(res)


t = int(input())
while t != 0:
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	st = input()
	cnt = 0
	c1 = 0
	temp = 0
	a = st.split('1')
	num = int(len(a))
	if num == 1:
		cnt += int(int(len(st)) / (k + 1) + (int(len(st)) % (k + 1) != 0))
		print(cnt)
		t -= 1
		continue
	for i in range(num):
		if a[i] != '':
			if i != 0 and i != num - 1:
				if int(len(a[i])) >= 2 * k:
					temp = int(len(a[i])) - 2 * k
					j = 1
					while j <= temp:
						c1 += 1
						j += k + 1
			elif i == 0 or i == num - 1:
				if int(len(a[i])) >= k:
					temp = int(len(a[i])) - k
					j = 1
					while j <= temp:
						c1 += 1
						j += k + 1
	cnt += c1
	print(cnt)
	t -= 1


T = int(input())
for test in range(T):
	(n, k) = map(int, input().split())
	l = input()
	ans = 0
	cur = k
	for i in range(n):
		if l[i] == '1':
			cur = 0
		else:
			cur += 1
		if cur >= k * 2 + 1 or (cur >= k + 1 and i == n - 1):
			cur = k
			ans += 1
	print(ans)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	st = input()
	f = 0
	while f < n:
		if st[f] == '1':
			break
		f += 1
	d = 0
	ans = f // (k + 1)
	if f != n:
		for i in range(f, n):
			if st[i] != '1':
				d += 1
			else:
				x = (d - k) // (k + 1)
				d = 0
				if x > 0:
					ans += x
	else:
		ans = 1 + (f - 1) // (k + 1)
	if d > 0:
		x = d // (k + 1)
		if x > 0:
			ans += x
	print(ans)


for _ in range(int(input())):
	(l, k) = map(int, input().split())
	s = input()
	resCount = 0
	if s.count('0') == l:
		for i in range(0, l, k + 1):
			resCount += 1
	else:
		sc = s[::-1]
		firstIndex = s.index('1')
		lastIndex = l - sc.index('1') - 1
		resCount += firstIndex // (k + 1)
		resCount += (l - (lastIndex + 1)) // (k + 1)
		zeroCount = 0
		if firstIndex != lastIndex:
			for i in range(firstIndex + 1, lastIndex + 1):
				if s[i] == '0':
					zeroCount += 1
				else:
					if zeroCount >= 2 * k + 1:
						resCount += 1
						zeroCount -= 2 * k + 1
						if zeroCount > 0:
							resCount += zeroCount // (k + 1)
					zeroCount = 0
	print(resCount)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	st = input()
	cnt = 0
	ans = 0
	firstone = 0
	for h in range(n):
		if st[h] == '0':
			cnt += 1
		else:
			firstone = 1
			cnt = 0
		if firstone == 0:
			if cnt == m + 1:
				ans += 1
				cnt = m
				firstone = 1
		if cnt == 2 * m + 1:
			ans += 1
			cnt = m
		if h == n - 1:
			if cnt >= m + 1:
				ans += 1
	if m >= n:
		inty = int(st)
		if inty == 0:
			ans += 1
	print(ans)


import math

def solve(a, n, k):
	res = 0
	start = 0
	f = 0
	if sum(a[:k + 1]) == 0:
		res += 1
		start = 1
		f = 1
	c = 0
	while start < n:
		if a[start] == 0:
			c += 1
		elif a[start] == 1:
			c = k
			start += k + 1
			continue
		if c == 2 * k + 1:
			res += 1
			c = k
			f = 0
		start += 1
		if start == n and c > k:
			res += 1
	return res
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, list(input())))
	res = solve(a, n, k)
	print(res)


cases = int(input())
for t in range(cases):
	(n, k) = list(map(int, input().split()))
	s = input()
	s = '1' + '0' * k + s + '0' * k + '1'
	c = 0
	z = 0
	for i in s:
		if i == '0':
			z += 1
		if i == '1':
			z = 0
		if z == 2 * k + 1:
			c += 1
			z = k
	print(c)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	l = []
	for i in range(n):
		if s[i] == '1':
			l.append(i)
	ans = 0
	if len(l) == 0:
		ans += 1
		l.append(0)
		l.append(n)
	elif l[0] != 0:
		if l[0] - 1 >= k:
			ans += 1
			t = abs(l[0] - 1)
			z = t % (k + 1)
			if z == k:
				ans += t // (k + 1)
			else:
				ans += max(0, t // (k + 1) - 1)
		l.append(n)
	else:
		l.append(n)
	for i in range(len(l) - 1):
		t = abs(l[i + 1] - l[i] - 1)
		z = t % (k + 1)
		if l[i + 1] != n:
			if z == k:
				ans += t // (k + 1)
			else:
				ans += max(0, t // (k + 1) - 1)
		else:
			ans += t // (k + 1)
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	dist = k
	count = 0
	for i in range(n):
		if s[i] == '1':
			if dist < k:
				count -= 1
			dist = 0
		elif dist >= k:
			count += 1
			dist = 0
		else:
			dist += 1
	print(count)


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	s = input()
	arr = []
	ans = 0
	for i in range(n):
		if s[i] == '1':
			arr.append(i)
	if len(arr) == 0:
		print((n + k) // (k + 1))
	else:
		ans += (arr[0] + k + 1) // (k + 1) - 1
		for i in range(1, len(arr)):
			ans += (arr[i] - arr[i - 1] + k + 1) // (k + 1) - 2
		ans += (n - 1 - arr[len(arr) - 1] + (k + 1)) // (k + 1) - 1
		print(ans)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = input()
	prev = 0
	c = 0
	if s[0] == '0':
		c += 1
	for (i, x) in enumerate(s):
		if i == 0:
			continue
		if x == '1':
			if i - prev <= k:
				c -= 1
			prev = i
		elif i - prev > k:
			c += 1
			prev = i
	print(c)


t = int(input())
for test_case in range(t):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input()))
	ones = [-k - 1]
	more = 0
	for (index, val) in enumerate(arr):
		if val:
			ones.append(index)
	if len(ones) == 1:
		more = (n + k) // (k + 1)
	else:
		ones.append(n + k)
		for i in range(len(ones) - 1):
			(a, b) = (ones[i], ones[i + 1])
			while b - a - 1 >= 2 * k + 1:
				more += 1
				a += k + 1
	print(more)


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	a = input()
	a = list(a)
	occ = 0
	x = []
	for j in range(len(a)):
		if a[j] == '1':
			x.append(j)
	j = 0
	if len(x) != 0:
		a = 0
		b = x[0]
		while a <= b - k - 1:
			occ = occ + 1
			a = a + k + 1
		while j < len(x) - 1:
			if b + k + 1 <= x[j + 1] - k - 1:
				occ = occ + 1
				b = b + k + 1
			else:
				b = x[j + 1]
				j = j + 1
		a = x[len(x) - 1]
		while a + k + 1 < n:
			occ = occ + 1
			a = a + k + 1
	else:
		for j in range(0, n, k + 1):
			occ = occ + 1
	print(occ)


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	s = str(input())
	count = 0
	dist = k
	for i in range(n):
		if s[i] == '0':
			dist += 1
		else:
			dist = 0
		if dist == 2 * k + 1:
			count += 1
			dist = k
	if dist >= k + 1:
		count += 1
	print(count)
	t -= 1


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	cnt = 0
	prev = -(k + 1)
	for i in range(n):
		if s[i] == '0':
			if i - prev - 1 >= k:
				cnt += 1
				prev = i
		else:
			if i - prev - 1 < k:
				cnt -= 1
			prev = i
	print(cnt)


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	s = input()
	s = list(s)
	s = [int(i) for i in s]
	blockedpos = set()
	for (idx, val) in enumerate(s):
		if val == 1:
			x = range(idx - k, idx + k + 1)
			for i in x:
				if i >= 0 and i < n:
					blockedpos.add(i)
	res = 0
	for (idx, val) in enumerate(s):
		if val == 0:
			if idx not in blockedpos:
				res += 1
				val = 1
				x = range(idx - k, idx + k + 1)
				for i in x:
					if i >= 0 and i < n:
						blockedpos.add(i)
	print(res)


n = int(input())
r = [0] * n
for i in range(n):
	(size, k) = map(int, input().split())
	cont = 0
	ultimo_1 = 0
	string = input()
	if string[0] == '0':
		cont += 1
		ultimo_1 = 0
	for j in range(1, size):
		if string[j] == '1':
			if j - ultimo_1 - k <= 0:
				cont -= 1
			ultimo_1 = j
		elif j - ultimo_1 - k > 0:
			cont += 1
			ultimo_1 = j
	r[i] = cont
for c in r:
	print(c)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	k = l[1]
	s = input()
	c = 0
	cp = 0
	if s[0] != '1':
		c += 1
		cp = 0
	i = 1
	while i < l[0]:
		if s[i] == '1':
			if i - cp <= k:
				c -= 1
			cp = i
		elif i - cp > k:
			c += 1
			cp = i
		i += 1
	print(c)


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


import math
import os
import random
import re
import sys
t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	arr = list(map(int, input()))
	arr = [0] * k + arr + [0] * k
	r = 0
	l = k
	ans = 0
	for i in range(k):
		if arr[k + 1 + i] == 0:
			r += 1
	if arr[k] == 0 and r == k:
		ans += 1
		arr[k] = 1
	for i in range(k + 1, len(arr) - k):
		if arr[i - k - 1] == 0:
			l -= 1
		if arr[i - 1] == 0:
			l += 1
		if arr[i] == 0:
			r -= 1
		if arr[i + k] == 0:
			r += 1
		if arr[i] == 0 and r == k and (l == k):
			ans += 1
			arr[i] = 1
	print(ans)


from math import ceil
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().strip().split())
	s = input().strip()
	res = 0
	strips = s.split('1')
	if len(strips) == 1:
		print(1 + (n - 1) // (k + 1))
	else:
		start = strips[0]
		end = strips[-1]
		strips = strips[1:-1]
		res = max(ceil((len(start) - k) / (k + 1)), 0) + max(ceil((len(end) - k) / (k + 1)), 0)
		for strip in strips:
			res += max(0, ceil((len(strip) - 2 * k) / (k + 1)))
		print(res)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	lis = list(map(int, list(input())))
	flag = 0
	coun = 0
	set1 = []
	i = 0
	while i < n:
		if flag == 0:
			if lis[i] != 1:
				if i + k < n:
					for j in range(i + 1, i + k + 1):
						if lis[j] == 0:
							continue
						else:
							flag = k
							i = j + 1
							break
					if flag == 0:
						coun = coun + 1
						flag = k
						i = i + 1
				else:
					for j in range(i + 1, n):
						if lis[j] == 0:
							continue
						else:
							flag = k
							i = j + 1
							break
					if flag == 0:
						coun = coun + 1
						flag = k
						i = i + 1
			else:
				i = i + 1
				flag = k
		elif lis[i] == 1:
			i = i + 1
			flag = k
		else:
			flag = flag - 1
			i = i + 1
	print(coun)


t = int(input())
for hh in range(0, t):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	s = list(s)
	a = [0] * (n + 1)
	pre = [0] * (n + 1)
	for i in range(0, len(s)):
		if s[i] == '1':
			a[i] = 1
	pre[0] = a[0]
	for i in range(1, n + 1):
		pre[i] = pre[i - 1] + a[i]
	i = 0
	ans = 0
	preupd = 0
	while i < n:
		if s[i] == '0':
			mx = min(n - 1, i + k)
			mn = max(0, i - k)
			if mn == 0:
				tot = pre[mx] + preupd
			else:
				tot = pre[mx] + preupd - pre[mn - 1]
			if tot == 0:
				ans += 1
				s[i] = '1'
				a[i] = 1
				preupd += 1
		pre[i] += preupd
		i += 1
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	s = input()
	gap = []
	ans = count = 0
	for i in range(len(s)):
		if int(s[i]) == 1:
			gap.append(count)
			count = 0
		elif int(s[i]) == 0:
			count += 1
		if i == len(s) - 1:
			gap.append(count)
	for i in range(len(gap)):
		if gap[i] > 2 * b and i != 0 and (i != len(gap) - 1):
			ans += (gap[i] - 2 * b - 1) // (b + 1) + 1
		if gap[i] > b and (i == 0 and i != len(gap) - 1) or (i != 0 and i == len(gap) - 1):
			ans += gap[i] // (b + 1)
		if gap[i] > 0 and i == 0 and (i == len(gap) - 1):
			ans += 1 + (gap[i] - 1) // (b + 1)
	print(ans)


t = int(input())
for _ in range(t):
	(n, d) = [int(i) for i in input().split()]
	arr = [i for i in input()]
	ind = []
	for i in range(n):
		if arr[i] == '1':
			ind.append(i)
	ans = 0
	if len(ind) == 0:
		ans = n // (d + 1)
		if n % (d + 1) != 0:
			ans += 1
		print(ans)
	else:
		for i in range(len(ind)):
			if i == 0:
				diff = max(0, ind[i] - 0 - d)
				ans += diff // (d + 1)
				if diff % (d + 1) != 0:
					ans += 1
			else:
				diff = max(0, ind[i] - ind[i - 1] - d - d - 1)
				ans += diff // (d + 1)
				if diff % (d + 1) != 0:
					ans += 1
		diff = n - 1 - ind[-1] - d
		ans += diff // (d + 1)
		if diff % (d + 1) != 0:
			ans += 1
		print(ans)


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]:
			t += max(dist[len(dist) - 1] // (k + 1), 0)
		print(t)


m = int(input())
for i in range(m):
	(n, k) = map(int, input().split())
	s = input()
	s = '1' + '0' * k + s + '0' * k + '1'
	r = 0
	p = 0
	while s.find('1', p + 1) > 0:
		p2 = s.find('1', p + 1)
		d = p2 - p - 1
		d = d - k
		if d > 0:
			r += d // (k + 1)
		p = p2
	print(r)


import math
t = int(input())
while t:
	inp1 = list(map(int, input().strip().split()))[:2]
	(n, k) = (inp1[0], inp1[1])
	s = input()
	arr = []
	for i in range(len(s)):
		if s[i] == '1':
			arr.append(i)
	if len(arr) == 0:
		print(math.ceil(len(s) / (k + 1)))
	else:
		count = 0
		if arr[0] - 0 > k:
			arr.insert(0, 0)
			count += 1
		if len(s) - 1 - arr[-1] > k:
			arr.append(len(s) - 1)
			count += 1
		for i in range(1, len(arr)):
			diff = arr[i] - arr[i - 1]
			diff -= 1
			if diff > 2 * k:
				diff -= 2 * k
				count += math.ceil(diff / (k + 1))
		print(count)
	t -= 1


t = int(input())
while t:
	t -= 1
	(present, ans, cnt) = (0, 0, 0)
	(n, k) = map(int, input().split())
	s = input()
	for i in range(n):
		if s[i] == '1':
			if present:
				ans += max(0, (cnt + 1) // (k + 1) - 1)
			else:
				ans += cnt // (k + 1)
			present = 1
			cnt = 0
		else:
			cnt = cnt + 1
	if present:
		ans += cnt // (k + 1)
	else:
		ans = 1 + (n - 1) // (k + 1)
	print(ans)


t = int(input())
while t:
	(n, k) = list(map(int, input().split()))
	a = list(input())
	left = [-1 for i in range(n)]
	p = -1
	for i in range(n):
		left[i] = p
		if a[i] == '1':
			p = i
	p = -1
	c = 0
	for i in range(n - 1, -1, -1):
		if a[i] == '1':
			p = i
			continue
		elif left[i] == -1:
			if p == -1:
				a[i] = '1'
				p = i
				c += 1
			else:
				d = p - i
				if d > k:
					a[i] = '1'
					p = i
					c += 1
		elif p == -1:
			d = i - left[i]
			if d > k:
				a[i] = '1'
				p = i
				c += 1
		else:
			d1 = i - left[i]
			d2 = p - i
			if d1 > k and d2 > k:
				a[i] = '1'
				p = i
				c += 1
	print(c)
	t -= 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	j = 0
	c = []
	r = 0
	while j < n:
		if s[j] == '1':
			c.append(j)
		j += 1
	if len(c) == 0:
		c.append(0)
		r += 1
	j = 0
	r += int(c[0] / (k + 1))
	while j < len(c) - 1:
		p = c[j + 1] - c[j] - 1
		if p >= 2 * k + 1:
			r += 1
			p -= 2 * k + 1
			r += p // (k + 1)
		j += 1
	r += int((n - c[-1] - 1) / (k + 1))
	print(r)


import sys
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
t = inp()
for _ in range(t):
	(n, k) = inpl()
	s = input()
	z = []
	now = -1
	cnt = 1
	for (i, x) in enumerate(s):
		if i == 0:
			now = x
			continue
		if now == x:
			cnt += 1
		else:
			z.append(cnt)
			now = x
			cnt = 1
	z.append(cnt)
	res = 0
	fi = 1
	if s[0] == '0':
		if z[0] >= k + 1 or len(z) == 1:
			res += 1
			z[0] -= 1
		fi = 0
	if s[-1] == '0':
		if z[-1] >= k + 1:
			res += 1
			z[-1] -= 1
	for x in z[fi::2]:
		rem = x
		if x >= k * 2 + 1:
			res += 1
			rem -= k * 2 + 1
		else:
			continue
		res += rem // (k + 1)
	print(res)


import math

def freetables(n, k, s):
	free = 0
	zeros = 0
	if s[0] == '0':
		for (i, ch) in enumerate(s):
			if ch == '0':
				zeros += 1
			else:
				free += math.ceil(max(zeros - k, 0) / (k + 1))
				res = i
				zeros = 0
				break
	else:
		res = -1
	if zeros == len(s):
		return math.ceil(zeros / (k + 1))
	for ch in s[res + 1:]:
		if ch == '0':
			zeros += 1
		else:
			free += math.ceil(max(zeros - 2 * k, 0) / (k + 1))
			zeros = 0
	free += math.ceil(max(zeros - k, 0) / (k + 1))
	return free
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	print(freetables(n, k, s))


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from collections import Counter
from bisect import bisect_left
import sys
from queue import PriorityQueue
mod = 1000000007

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def myCode():
	(n, k) = In()
	s = input()
	d = [-k - 1]
	for i in range(n):
		if s[i] == '1':
			d.append(i)
	d.append(n + k)
	ans = 0
	for i in range(len(d) - 1):
		dist = d[i + 1] - d[i] - (k + 1)
		ans += dist // (k + 1)
	print(ans)

def main():
	for t in range(I()):
		myCode()
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	i = 0
	while i < n:
		if s[i] == '1':
			break
		i += 1
	if i == n:
		ans = (n + k) // (k + 1)
		print(ans)
		continue
	else:
		ans = i // (k + 1)
	temp = 0
	i += 1
	while i < n:
		if s[i] == '1':
			ans += (temp - k) // (k + 1)
			temp = 0
		else:
			temp += 1
		i += 1
	ans += temp // (k + 1)
	print(ans)


def problem():
	(n, k) = [int(s) for s in input().split()]
	string = input()
	zeros = []
	curr_zeros = k
	for s in string:
		if s == '1':
			zeros.append(curr_zeros)
			curr_zeros = 0
			continue
		curr_zeros += 1
	zeros.append(curr_zeros + k)
	ret = 0
	for zero in zeros:
		if zero > k:
			ret += (zero - k) // (k + 1)
	print(ret)
for i in range(int(input())):
	problem()


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())
t = oint()
for _ in range(t):
	(n, k) = rint()
	s = get_str()
	i1 = 0
	cnt = 0
	if s[0] == '0':
		cnt += 1
	for i in range(1, n):
		if s[i] == '1':
			if k >= i - i1:
				cnt -= 1
			i1 = i
		elif k == i - i1 - 1:
			i1 = i
			cnt += 1
	print(cnt)


tests = int(input())
for i in range(tests):
	numbers = input().split()
	n = int(numbers[0])
	k = int(numbers[1])
	line = input()
	left = k
	seats = 0
	for x in range(n):
		if line[x] == '1':
			left = 0
		elif left < k:
			left += 1
		else:
			result = 1
			for y in range(x + 1, min(x + k + 1, n)):
				if line[y] != '0':
					result = 0
					break
			if result == 1:
				seats += 1
			left = 0
	print(seats)


tc = int(input())
for zzz in range(tc):
	(n, k) = map(int, input().split())
	s = input()
	brr = []
	for ele in s:
		brr.append(ele)
	i = 0
	while i < n:
		if brr[i] == '1':
			for j in range(1, k + 1):
				w = i - j
				if w < 0:
					break
				if brr[w] == 2:
					break
				brr[w] = '2'
			z = 0
			for j in range(1, k + 1):
				w = i + j
				z = w
				if w >= n:
					break
				brr[w] = '2'
			i = z
		else:
			i += 1
	i = 0
	co = 0
	while i < n:
		if brr[i] == '0':
			co += 1
			i += k
		i += 1
	print(co)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(s, i, cnt1) = (list(input()), 0, 0)
	while i < n:
		if s[i] == '1':
			cnt2 = 0
			j = i + 1
			while j < n:
				if s[j] == '0':
					cnt2 += 1
				else:
					break
				if cnt2 == k + 1 and s[j:j + k + 1:1].count('1') == 0:
					cnt1 += 1
					s[j] = '1'
					break
				j += 1
			i = j - 1
		else:
			j = i + 1
			cnt2 = 1
			while j < n:
				if s[j] == '1':
					break
				else:
					cnt2 += 1
				j += 1
			if j == n:
				cnt1 = n // (k + 1)
				if n % (k + 1):
					cnt1 += 1
			else:
				cnt1 = cnt2 // (k + 1)
			i = j - 1
		i += 1
	print(cnt1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	if n == 1:
		if a[0] == '0':
			print(1)
		else:
			print(0)
	else:
		aa = []
		for i in a:
			aa.append(int(i))
		c = 0
		i = 0
		while i < n:
			if aa[i] == 0:
				j = i - k
				r = 0
				if j < 0:
					j = 0
				jj = i + k + 1
				if jj > n:
					jj = n
				s = sum(aa[j:jj])
				s1 = sum(aa[i + 1:jj])
				if s == 0:
					r = 0
				else:
					r = 1
				if r == 0:
					aa[i] = 1
					c += 1
					i = jj - 1
				elif s1 != 0:
					i = jj - 1
				else:
					i = i + 1
			else:
				i = i + k
		print(c)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	i = 0
	ans = 0
	while i < len(s):
		j = i + 1
		while j < n and s[j] == '0':
			j += 1
		if s[i] == '1':
			left = k
		else:
			left = 0
		if j < n and s[j] == '1':
			right = k
		else:
			right = 0
		lens = j - i
		if left == k:
			lens -= 1
		lens -= left + right
		if lens > 0:
			ans += (lens + k) // (k + 1)
		i = j
	print(ans)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	pre = []
	for i in range(n):
		if s[i] == '1':
			pre.append(i)
	if pre == []:
		print(math.ceil(n / (k + 1)))
	else:
		count = 0
		for i in range(len(pre) - 1):
			tem = max(0, (pre[i + 1] - pre[i] - k - 1) // (k + 1))
			count += tem
		first = pre[0]
		count += max(0, first // (k + 1))
		last = n - pre[-1]
		count += max(0, (last - 1) // (k + 1))
		print(count)


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		(N, K) = map(int, input().split())
		S = input()
		s = S.split('1')
		n = len(s)
		if n == 1:
			(d, m) = divmod(N, K + 1)
			if m:
				print(d + 1)
			else:
				print(d)
			continue
		ans = len(s[0]) // (K + 1)
		ans += len(s[-1]) // (K + 1)
		for i in range(1, n - 1):
			ans += (len(s[i]) - K) // (K + 1)
		print(ans)
main()


def solve():
	(N, K) = map(int, input().split())
	S = list(map(int, list(input())))
	b = []
	for i in range(N):
		if S[i] == 1:
			b.append(i)
	c = 0
	b.insert(0, -(K + 1))
	b.append(N + K)
	for i in range(1, len(b)):
		c += (b[i] - b[i - 1]) // (K + 1) - 1
	return c
t = int(input())
while t > 0:
	t -= 1
	ans = solve()
	print(ans)


from math import *
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	a = -(k + 1)
	b = n + k
	c = 0
	for i in range(n):
		if s[i] == '1':
			dif = i - a - 1
			if dif >= 2 * k + 1:
				dif = dif - 2 * k
				c = c + max(ceil(dif / (k + 1)), 1)
			a = i
	dif = b - a - 1
	if dif >= 2 * k + 1:
		dif = dif - 2 * k
		c = c + max(ceil(dif / (k + 1)), 1)
	print(c)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	c = sum = 0
	p1 = p2 = -1
	for j in range(n):
		if s[j] == '1':
			p1 = j
			break
	for j in range(n - 1, -1, -1):
		if s[j] == '1':
			p2 = j
			break
	for j in range(p1 + 1, p2 + 1):
		if s[j] == '0':
			c = c + 1
		else:
			sum = sum + (c - k) // (k + 1)
			c = 0
	if p1 == -1:
		ans = (n - 1) // (k + 1) + 1
	else:
		ans = sum + p1 // (k + 1) + (n - 1 - p2) // (k + 1)
	print(ans)


from sys import stdin
input = stdin.readline

def main():
	test = int(input())
	for _ in range(test):
		(n, k) = [int(i) for i in input().split(' ')]
		c = 0
		l = list(input().strip())
		flag = False
		ans = 0
		for i in range(n):
			if l[i] == '0':
				c += 1
			elif l[i] == '1':
				c -= k
				if flag:
					c -= k
				else:
					flag = True
				ans += max(c // (k + 1), 0)
				if c > 0 and c % (k + 1) != 0:
					ans += 1
				c = 0
		if flag:
			c -= k
		ans += max(c // (k + 1), 0)
		if c > 0 and c % (k + 1) != 0:
			ans += 1
		print(ans)
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	s = '0' * k + s + '0' * k
	ans = 0
	segs = [len(seg) for seg in s.split('1')]
	for seg in segs:
		ans += (seg - k) // (k + 1)
	print(ans)


def f1(x, k):
	return x // (k + 1)

def f11(x, k):
	return (x - k) // (k + 1)
for t in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	if s.find('1') == -1:
		z = 1 + f1(len(s) - 1, k)
	else:
		ss = s.split('1')
		m = [len(x) for x in ss]
		z1 = f1(m[0], k) + f1(m[0 - 1], k)
		z = sum([f11(x, k) for x in m[1:-1]]) + z1
	print(z)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n, k) = I()
	s = list(input().strip())
	an = 0
	c = f = 0
	r = s.index('1') if '1' in s else 2 * (n + k)
	if s[0] == '0' and r > k:
		s[0] = '1'
		an += 1
	for i in range(n):
		if s[i] == '0':
			c += 1
		else:
			c = 0
		if c == 2 * k + 1:
			s[i - k] = '1'
			an += 1
			c = k
	if c >= k + 1:
		an += 1
		s[-1] = '1'
	print(an)


import math
import sys

def calculate(tables, minDistance):
	personInBack = False
	availableTableCount = 0
	validChairCount = 0
	for table in tables:
		if table == '1':
			if personInBack:
				validChairCount -= minDistance
			validChairCount -= minDistance
			if validChairCount > 0:
				availableTableCount += math.ceil(validChairCount / (minDistance + 1))
			validChairCount = 0
			personInBack = True
		else:
			validChairCount += 1
	if personInBack:
		validChairCount -= minDistance
	if validChairCount > 0:
		availableTableCount += math.ceil(validChairCount / (minDistance + 1))
	return availableTableCount

def getInputs():
	numOfInput = sys.stdin.readline()
	for inputIndex in range(0, int(numOfInput)):
		firstInput = sys.stdin.readline().rstrip().split(' ')
		minDistance = int(firstInput[1])
		tables = sys.stdin.read(int(firstInput[0]))
		sys.stdin.readline()
		yield (tables, minDistance)
for lineInput in getInputs():
	result = calculate(*lineInput)
	print(result)


import math
t = int(input())
for j in range(t):
	(n, k) = map(int, input().split())
	a = input()
	le = n
	one = a.count('1')
	start = 0
	end = n
	tot = 0
	if one == 0:
		if n == k:
			print(1)
		else:
			print(math.ceil(n / (k + 1)))
	else:
		b = a.index('1', start)
		le = b - start
		tot += le // (k + 1)
		start = b + 1
		for i in range(one - 1):
			b = a.index('1', start)
			le = b - start
			tot += le // (k + 1)
			if le % (k + 1) < k and le // (k + 1) > 0:
				tot -= 1
			start = b + 1
		tot += (n - b - 1) // (k + 1)
		print(tot)


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def solve():
	for _ in range(ii()):
		(n, k) = mi()
		s = si()
		c = 0
		ans = 0
		if '1' not in s:
			for i in range(0, n, k + 1):
				ans += 1
			print(ans)
			continue
		for i in range(n):
			if s[i] == '0':
				c += 1
			else:
				ans += c // (k + 1)
				c = 0
				for j in range(i + 1, n):
					if s[j] == '0':
						c += 1
					else:
						if c > k:
							c -= k
							ans += c // (k + 1)
						c = 0
				break
		ans += c // (k + 1)
		print(ans)
solve()


t = int(input())

def f(n, k, s):
	if n == 1:
		if s == '0':
			return 1
		return 0
	a = [0]
	i = 0
	while i < n and s[i] == '0':
		a[0] += 1
		i += 1
	while i < n:
		i += 1
		b = 0
		while i < n and s[i] == '0':
			b += 1
			i += 1
		a.append(b)
	if len(a) == 1:
		if a[0] % (k + 1) == 0:
			return a[0] // (k + 1)
		return a[0] // (k + 1) + 1
	q = a[0] // (k + 1)
	for m in range(1, len(a) - 1):
		if a[m] - k > 0:
			q += (a[m] - k) // (k + 1)
	q += a[-1] // (k + 1)
	return q
for _ in range(t):
	(n, k) = tuple(map(int, input().split()))
	s = input()
	print(f(n, k, s))


for kf in range(int(input())):
	(n, k) = map(int, input().split())
	t = list(input())
	if n == 1:
		if t[0] != '1':
			print(1)
		else:
			print(0)
	elif n <= k and t.count('1') != 0:
		print(0)
	else:
		ones = []
		for g in range(n):
			if t[g] == '1':
				ones.append(g)
		ans = 0
		if len(ones) != 0:
			for i in range(0, len(ones) - 1):
				if ones[i + 1] - ones[i] - 1 >= 2 * k + 1:
					b = ones[i + 1] - ones[i] - 1 - k
					ans += b // (k + 1)
			if ones[0] != 0:
				b = ones[0]
				if b >= k + 1:
					ans += b // (k + 1)
			y = len(ones)
			if ones[y - 1] != n - 1:
				b = n - ones[y - 1] - 1
				if b >= k + 1:
					ans += b // (k + 1)
			print(ans)
		elif n <= k:
			print(1)
		elif n % (k + 1) == 0:
			print(n // (k + 1))
		else:
			print(n // (k + 1) + 1)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = list(map(int, input()))
	t = 0
	indices = range(n)
	for (i, v) in enumerate(s):
		if v == 1:
			left = max(0, i - k)
			right = min(i + k + 1, n)
			s[left:right] = [2] * len(s[left:right])
	for (i, v) in enumerate(s):
		if v == 0:
			t += 1
			left = max(0, i - k)
			right = min(i + k + 1, n)
			s[left:right] = [2] * len(s[left:right])
	print(t)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = str(input())
	count0 = 0
	count1 = 0
	ans = 0
	li = []
	for i in range(0, n):
		if s[i] == '1':
			li.append(i)
	if len(li) == 0:
		noz = n
		ans = math.ceil(n / (k + 1))
	elif len(li) == 1:
		ans += math.ceil(max(0, li[0] - k) / (k + 1))
		ans += math.ceil((n - 1 - min(li[-1] + k, n - 1)) / (k + 1))
	else:
		ans += math.ceil(max(0, li[0] - k) / (k + 1))
		ans += math.ceil((n - 1 - min(li[-1] + k, n - 1)) / (k + 1))
		for i in range(1, len(li)):
			noz = max(0, li[i] - k - (li[i - 1] + k)) - 1
			ans += math.ceil(noz / (k + 1))
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(input())
	c = 0
	t = 0
	nex = 0
	if n == k:
		if n == l.count('0'):
			print(1)
		else:
			print(0)
		continue
	if l[0] == '0':
		for i in range(k + 1):
			if l[i] == '1':
				break
			else:
				t += 1
		if t == k + 1:
			c += 1
			nex = 1
	if l[0] == '1':
		nex = 1
	t = 0
	for i in range(nex, n):
		if l[i] == '0':
			t += 1
		if l[i] == '1':
			t = 0
		if t == 2 * k + 1:
			c += 1
			t = k
	if t >= k + 1 and l[-1] != '1':
		c += 1
	print(c)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(10000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(n, k) = int_array()
	s = input().strip()
	pts = []
	for i in range(n):
		if s[i] == '1':
			pts.append(i)
	if len(pts) == 0:
		ans = n // (k + 1)
		if n % (k + 1):
			ans += 1
		print(ans)
		continue
	seg = []
	if s[0] == '0':
		if pts[0] > k:
			seg.append((0, pts[0] - k - 1))
	for i in range(1, len(pts)):
		lst = pts[i - 1]
		cur = pts[i]
		st = lst + k + 1
		en = cur - k - 1
		if st <= en and en < n:
			seg.append((st, en))
	if pts[-1] + k + 1 < n:
		seg.append((pts[-1] + k + 1, n - 1))
	ans = 0
	for el in seg:
		st = el[0]
		en = el[1]
		lennon = en - st + 1
		ans += lennon // (k + 1)
		if lennon % (k + 1):
			ans += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	chan = 0
	i = 0
	while i <= n - 1:
		if s[i] == '1':
			i += k + 1
		else:
			is_pos = True
			i1 = i
			while i <= i1 + k and i <= n - 1:
				if s[i] == '1':
					is_pos = False
					i += k + 1
					break
				i += 1
			if is_pos:
				chan += 1
	print(chan)


from sys import stdin, stdout
q = int(input())
for i in range(q):
	(n, k) = list(map(int, stdin.readline().split()))
	a = input()
	d = k + 1
	s = 0
	cnt = 0
	if a[0] == '0':
		flag = 0
	else:
		flag = 1
	for i in a:
		if i == '0':
			s += 1
		elif s > 0:
			if flag == 0:
				flag = 1
				cnt += s // (k + 1)
			else:
				rem = s % d
				if rem == k:
					cnt += s // d
				else:
					cnt += s // d - 1
			s = 0
	if s == len(a):
		if k >= len(a):
			cnt = 0
			cnt += 1
		else:
			cnt = 0
			l = s % (k + 1)
			if l > 0:
				cnt += 1
			cnt += s // (k + 1)
	elif s > 0:
		cnt += s // (k + 1)
	print(cnt)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = input()
	ans = 0
	x = k
	for j in range(n):
		if a[j] == '1':
			if x > 2 * k:
				ans += (x - k) // (k + 1)
			x = 0
		else:
			x += 1
	if x > k:
		ans += x // (k + 1)
	print(ans)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	t = [0] * (n + 1)
	for i in range(n):
		if s[i] == '1':
			t[max(0, i - k)] += 1
			t[min(n, i + k + 1)] -= 1
	for i in range(1, n + 1):
		t[i] += t[i - 1]
	ok = 0
	ans = 0
	for i in range(n):
		if t[i] == 0:
			ok += 1
		else:
			ans += math.ceil(ok / (k + 1))
			ok = 0
	ans += math.ceil(ok / (k + 1))
	print(ans)


import pdb
t = int(input())
i = 0
while i < t:
	lst = input()
	lst = lst.split(' ')
	strLen = int(lst[0])
	k = int(lst[1])
	string = input()
	firstInd = string.find('1')
	if firstInd == -1:
		print(int((strLen - 1) / (k + 1)) + 1)
		i += 1
		continue
	j = 0
	count = 0
	crnt = firstInd
	originalFirstInd = firstInd
	while j < strLen:
		nextInd = string.find('1', crnt + 1)
		if nextInd == -1:
			tmp = (strLen - crnt - 1) / (k + 1)
			tmp = int(tmp)
			count += tmp
			break
		elif nextInd - crnt > 2 * k + 1:
			count += int((nextInd - crnt) / (k + 1)) - 1
		crnt = nextInd
		j = nextInd
	count += int(originalFirstInd / (k + 1))
	print(int(count))
	i += 1


for j in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s1 = '0' * n
	j = 0
	if s1 == s:
		d = n // (k + 1)
		r = n % (k + 1)
		if r != 0:
			print(d + 1)
		else:
			print(d)
		continue
	c = 0
	f = 0
	ans = 0
	while j < n:
		c += 1
		if s[j] == '1':
			c = 0
			f = 1
			j += 1
			continue
		if c == k + 1 and f == 0:
			ans += 1
			c = k
			f = 1
			j += 1
			continue
		if c == 2 * k + 1:
			ans += 1
			c = k
		j += 1
	if c >= k + 1:
		ans += 1
	print(ans)


from sys import stdin, stdout
for test in range(int(stdin.readline())):
	arr1 = [int(x) for x in stdin.readline().split()]
	n = arr1[0]
	k = arr1[1]
	arr = stdin.readline()
	arr = arr[:-1]
	ans = 0
	ptr1 = 0
	ptr2 = 0
	check = False
	check1 = False
	for i in range(n):
		if arr[i] == '1' and check == True:
			check = False
			check1 = True
			if ptr1 == 0:
				if ptr2 + 1 - k >= 0:
					ans = ans + (ptr2 + 1 - k) // (k + 1)
					if (ptr2 + 1 - k) % (k + 1) > 0:
						ans += 1
			elif ptr2 - ptr1 + 1 - 2 * k >= 0:
				ans = ans + (ptr2 - ptr1 + 1 - 2 * k) // (k + 1)
				if (ptr2 - ptr1 + 1 - 2 * k) % (k + 1) > 0:
					ans += 1
		elif arr[i] == '0' and check == False:
			check = True
			ptr1 = i
			ptr2 = i
		elif arr[i] == '0' and check:
			ptr2 += 1
		else:
			check1 = True
	if ptr2 == n - 1 and check1 == False and (arr[-1] == '0'):
		ans = n // (k + 1)
		if n % (k + 1) > 0:
			ans += 1
	elif ptr2 == n - 1 and check1 == True and (arr[-1] == '0'):
		if ptr2 - ptr1 + 1 - k >= 0:
			ans = ans + (ptr2 - ptr1 + 1 - k) // (k + 1)
			if (ptr2 - ptr1 + 1 - k) % (k + 1) > 0:
				ans += 1
	stdout.write(str(ans) + '\n')


t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split(' ')]
	a = input()
	l = k
	ans = 0
	for i in a:
		if i == '1':
			ans += max(0, (l - k) // (k + 1))
			l = 0
		else:
			l += 1
	ans += l // (k + 1)
	if l == n + k:
		print(l // (k + 1))
	else:
		print(ans)


for i1 in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s = s.rstrip()
	l = []
	for i in s:
		l.append(int(i))
	temp = 0
	for i in l:
		if i == 1:
			temp = 1
			break
	ans = 0
	if temp == 0:
		l[0] = 1
		ans += 1
	i = 0
	while i < n:
		if l[i] == 1:
			if i + k + 1 < n and l[i + k + 1] == 0:
				flag = 0
				j = 1
				while j <= k and i + k + j + 1 < n:
					if l[i + k + 1 + j] == 1:
						flag = 1
						break
					j += 1
				if flag == 0:
					l[i + k + 1] = 1
					ans += 1
			if i - k - 1 >= 0 and l[i - k - 1] == 0:
				flag = 0
				j = 1
				while j <= k and i - k - 1 - j >= 0:
					if l[i - k - 1 - j] == 1:
						flag = 1
						break
					j += 1
				if flag == 0:
					l[i - k - 1] = 1
					ans += 1
		i += 1
	l.reverse()
	i = 0
	while i < n:
		if l[i] == 1:
			if i + k + 1 < n and l[i + k + 1] == 0:
				flag = 0
				j = 1
				while j <= k and i + k + j + 1 < n:
					if l[i + k + 1 + j] == 1:
						flag = 1
						break
					j += 1
				if flag == 0:
					l[i + k + 1] = 1
					ans += 1
			if i - k - 1 >= 0 and l[i - k - 1] == 0:
				flag = 0
				j = 1
				while j <= k and i - k - 1 - j >= 0:
					if l[i - k - 1 - j] == 1:
						flag = 1
						break
					j += 1
				if flag == 0:
					l[i - k - 1] = 1
					ans += 1
		i += 1
	print(ans)


import sys
import math
from math import factorial as f
from collections import defaultdict as dd
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	(n, k) = map(int, input().split())
	s = input()
	ind = -1
	ans = 0
	k += 1
	flg = 0
	for i in range(n):
		if s[i] == '1':
			p = max(0, i - ind - 1)
			t = 0
			if ind != -1:
				p = max(0, p - k + 1)
				t = p // k
			else:
				t = p // k
			ans += t
			ind = i
			flg = 1
	if flg == 0:
		q = n // k
		if n % k:
			q += 1
		print(q)
		continue
	p = n - ind - 1
	ans += p // k
	print(ans)


t = int(input())
for T in range(t):
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	ans = 0
	for i in range(n):
		if i == 0 and s[i] == '0':
			count = k
		if i == n - 1 and s[i] == '0':
			count += 1
			if count > k:
				ans += 1
				break
		elif s[i] == '0':
			count += 1
		else:
			count = 0
		if count >= 2 * k + 1:
			count = k
			ans += 1
	print(ans)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ind = []
	for i in range(n):
		if s[i] == '1':
			ind.append(i)
	if len(ind) == 0:
		print(math.ceil(n / (k + 1)))
		continue
	count = ind[0] // (k + 1)
	for i in range(1, len(ind)):
		count += max(0, math.ceil((ind[i] - ind[i - 1] - 2 * k - 1) / (k + 1)))
	count += (n - ind[-1] - 1) // (k + 1)
	print(count)


from sys import stdin
from math import ceil
t = int(input())
for i in range(t):
	(n, k) = [int(num) for num in stdin.readline().split()]
	config = input()
	extra = 0
	start = 0
	intervals = []
	for index in range(len(config)):
		if config[index] == '1':
			intervals.append((start, index - k - 1))
			start = index + k + 1
	intervals.append((start, n - 1))
	for interval in intervals:
		(start, stop) = interval
		num = ceil((stop - start + 1) / (k + 1))
		extra += num if num > 0 else 0
	print(extra)


t = int(input())
import math
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	segs = []
	temp = 0
	for c in s:
		if c == '1':
			if temp != 0:
				segs.append(temp)
				temp = 0
		else:
			temp += 1
	else:
		if temp != 0:
			segs.append(temp)
	if len(segs) == 0:
		print(0)
	elif len(segs) == 1 and segs[0] == n:
		print(math.ceil(n / (k + 1)))
	elif len(segs) == 1 and segs[0] != n:
		if s[0] == '1' and s[-1] == '1':
			print(max(0, math.ceil((segs[0] - 2 * k) / (k + 1))))
		else:
			print(max(0, math.ceil((segs[0] - k) / (k + 1))))
	else:
		res = 0
		if s[0] == '0':
			res += max(0, math.ceil((segs[0] - k) / (k + 1)))
		else:
			res += max(0, math.ceil((segs[0] - 2 * k) / (k + 1)))
		if s[-1] == '0':
			res += max(0, math.ceil((segs[-1] - k) / (k + 1)))
		else:
			res += max(0, math.ceil((segs[-1] - 2 * k) / (k + 1)))
		for i in range(1, len(segs) - 1):
			res += max(0, math.ceil((segs[i] - 2 * k) / (k + 1)))
		print(res)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	temp = [float('inf')] * n
	for j in range(n - 1, -1, -1):
		if s[j] == '1':
			temp[j] = j
		elif j < n - 1:
			temp[j] = temp[j + 1]
	ans = 0
	last = float('-inf')
	for i in range(n):
		if s[i] == '1':
			last = i
		elif i - last > k and temp[i] - i > k:
			ans += 1
			last = i
	print(ans)


def socialDistance(a, x):
	i = 0
	people = 0
	while i < len(a):
		if a[i] == '0':
			j = 1
			while j <= x and i + j < len(a):
				if a[i + j] != '0':
					i += j
					break
				j += 1
			else:
				people += 1
		i += x + 1
	return people
tests = int(input())
for i in range(tests):
	(x, y) = map(int, input().split())
	arr = input()
	print(socialDistance(arr, y))


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	zero = 0
	ar = []
	i = 0
	while i < n:
		if s[i] == '1':
			i += k
			i += 1
			if zero > k:
				zero -= k
				ar.append(zero)
				zero = 0
			else:
				zero = 0
		else:
			i += 1
			zero += 1
	ar.append(zero)
	ans = 0
	for i in ar:
		ans += ceil(i / (k + 1))
	print(ans)


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	s = list(input())
	flag = 0
	count = 0
	index1 = 0
	if n <= k and s == list('0' * n):
		print('1')
		continue
	if s[0] == '0':
		if n >= k + 1:
			for i in range(min(n, k + 1)):
				if s[i] != '0':
					flag = 1
					break
			if flag == 0:
				count += 1
				index1 = 1
				s[0] = '1'
	flag = 0
	index2 = 0
	if s[n - 1] == '0':
		if -1 < n - k - 2:
			for i in range(n - 1, max(-1, n - k - 2), -1):
				if s[i] != '0':
					flag = 1
					break
			if flag == 0:
				count += 1
				index2 = 1
	temp = 0
	for i in range(index1, n - index2):
		if s[i] == '0':
			temp += 1
		else:
			if temp >= 2 * k + 1:
				count += 1
				temp -= 2 * k + 1
				count += int(temp / (k + 1))
			temp = 0
	if temp >= 2 * k + 1:
		count += 1
		temp -= 2 * k + 1
		count += int(temp / (k + 1))
	print(count)


import math

def num_input():
	return map(int, input().split())

def solve():
	(n, k) = num_input()
	s = list(input())
	prev = -1
	ans = 0
	flag = False
	for i in range(n):
		if s[i] == '1':
			flag = True
			if prev == -1:
				temp = i - (k + 1)
				while temp >= 0:
					ans += 1
					temp -= k + 1
				prev = i
			else:
				temp = i - (k + 1)
				while temp - prev > k:
					ans += 1
					temp -= k + 1
				prev = i
	if flag:
		remain = n - prev - 1
		if remain >= k:
			temp = prev + k + 1
			while temp < n:
				ans += 1
				temp += k + 1
		print(ans)
	elif n <= k:
		print(1)
	else:
		print(math.ceil(n / (k + 1)))
t = int(input())
for _ in range(t):
	solve()


from collections import Counter
from collections import defaultdict
from collections import deque
import math
import heapq
import sys
import io, os
input = sys.stdin.readline
from bisect import *
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().strip().split()))
rls = lambda : list(map(str, input().split()))
t = int(input())
for _ in range(0, t):
	(n, c) = rl()
	s = input()
	ans = [0]
	x = 1
	for i in range(0, n):
		if s[i] == '1':
			ans.append(x)
		x = x + 1
	ans.append(n + 1)
	res = 0
	k = 0
	a = ans
	if len(ans) == 2:
		print(max((n + c) // (c + 1), 1))
		continue
	for i in range(1, len(ans)):
		if i == 1 or i == len(ans) - 1:
			x = a[i] - a[i - 1] - 1
		else:
			x = a[i] - a[i - 1] - c - 1
		if x < 0:
			continue
		res = x // (c + 1)
		if res > 0:
			k = k + res
	print(k)


from sys import stdin

def r():
	return stdin.readline().strip()

def r_t(tp):
	return map(tp, r().strip().split())

def r_a(tp):
	return list(r_t(tp))

def solve(n, k, s):
	(ones, i, nxt, ans) = (list(), 0, 0, 0)
	for j in range(n):
		if s[j] == '1':
			ones.append(j)
	if not ones:
		return max(1, 1 + (n - 1) // (k + 1))
	ones.append(float('inf'))
	while i < n:
		if s[i] == '0':
			if i + k + 1 <= ones[nxt]:
				(ans, i) = (ans + 1, i + k + 1)
			else:
				i = ones[nxt]
		else:
			(i, nxt) = (i + k + 1, nxt + 1)
	return ans

def main():
	cases = int(r())
	for case in range(cases):
		(n, k) = r_t(int)
		s = r()
		print(solve(n, k, s))
main()


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


for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	a = input()
	filled = []
	for i in range(n):
		if a[i] == '1':
			filled.append(i + 1)
	ans = 0
	if filled == []:
		ans += n // (k + 1)
		if n % (k + 1) > 0:
			ans += 1
		print(ans)
		continue
	first = filled[0]
	right = first - k - 1
	ans += right // (k + 1)
	if right % (k + 1) > 0:
		ans += 1
	last = filled[-1]
	left = last + k + 1
	ans += (n - left + 1) // (k + 1)
	if (n - left + 1) % (k + 1) > 0:
		ans += 1
	for i in range(len(filled) - 1):
		left = filled[i] + k + 1
		right = filled[i + 1] - k - 1
		if right >= left:
			ans += (right - left + 1) // (k + 1)
			if (right - left + 1) % (k + 1) > 0:
				ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	l = [0 for j in range(n)]
	for j in range(n):
		if s[j] == '1':
			x = max(0, j - k)
			while x <= min(j + k, n - 1):
				l[x] = 1
				x += 1
	count = 0
	j = 0
	while j < n:
		if l[j] == 0:
			count += 1
			j += k + 1
		else:
			j += 1
	print(count)


import os
import sys
from io import BytesIO, IOBase
import threading
from math import floor
from collections import defaultdict

def seive(x):
	prime = [*range(x + 1)]
	for i in range(2, x + 1):
		if prime[i] == i:
			ind = i ** 2
			while ind < x + 1:
				if prime[ind] == ind:
					prime[ind] = i
				ind += i
	return prime

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		s = input() + '0' * k + '1'
		prev = 0
		ans = 0
		ind = [i for (i, j) in enumerate(s) if j == '1']
		prev = 0
		cnt = 0
		for i in range(len(ind)):
			while prev + k < ind[i]:
				cnt += 1
				prev = prev + k + 1
			prev = ind[i] + k + 1
		print(cnt)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import time, math, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count

def solve():
	(n, k) = IP()
	s = input()
	if s == '0' * n:
		cnt = 1
		for i in range(k + 1, n, k + 1):
			cnt += 1
		print(cnt)
	else:
		li = []
		for i in range(n):
			if s[i] == '1':
				li.append(i)
		cnt = 0
		x = li[0]
		for i in range(x - k - 1, -1, -k - 1):
			if i >= 0:
				cnt += 1
		x = li[-1]
		for i in range(x + k + 1, n, k + 1):
			cnt += 1
		curr = li[0]
		i = 1
		while curr < n and i < len(li):
			if curr + k + 1 <= li[i] - k - 1:
				cnt += 1
				curr = curr + k + 1
			else:
				curr = li[i]
				i += 1
		print(cnt)
t = II()
for i in range(t):
	solve()


import sys
for _ in range(int(sys.stdin.readline().rstrip())):
	(n, k) = list(map(int, sys.stdin.readline().rstrip().split()))
	bi = sys.stdin.readline().rstrip()
	re = 0
	last = -1
	for i in range(len(bi)):
		if bi[i] == '1' or i == len(bi) - 1:
			if bi[i] == '0' and (last < i or last < 0):
				re += 1
			j = i - (k + 1)
			while True:
				if j <= last:
					break
				j -= k + 1
				re += 1
			last = i + k
	print(re)


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


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
p = print
MAX = float('inf')
MIN = float('-inf')

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = ain()
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def main():
	for _ in range(iin()):
		(n, k) = ain()
		l = sin()
		d = deque([])
		for i in range(n):
			if l[i] == '1':
				d.append(i)
		if len(d) == 0:
			print(math.ceil(n / (k + 1)))
		else:
			ans = 0
			if d[0] - k > 0:
				ans += math.ceil((d[0] - k) / (k + 1))
			if n - d[-1] - k - 1 > 0:
				ans += math.ceil((n - d[-1] - k - 1) / (k + 1))
			prev = d[0]
			for i in range(1, len(d)):
				if d[i] - prev - 1 - k - k > 0:
					ans += math.ceil((d[i] - prev - k - k - 1) / (k + 1))
				prev = d[i]
			print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for tit in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	s = input()
	i = 0
	j = 1
	last_j = 0
	first_j = 0
	if n < 3:
		if s.find('1') != -1:
			print(0)
		else:
			print(1)
		continue
	tables = 0
	while i < j < n:
		if s[j] == '1':
			last_j = j
			if first_j == 0:
				first_j = j
			if i + k + 1 < j - k:
				tables += 1
				i += k + 1
			else:
				i = j
				j += 1
		else:
			j += 1
	if s[0] == '0':
		if k < first_j or first_j == 0:
			tables += 1
	i = last_j + k + 1
	while i < n:
		tables += 1
		i += k + 1
	print(tables)


t = int(input())
for i in range(t):
	arr = list(map(int, input().rstrip().split()))
	s = input()
	n = arr[0]
	k = arr[1]
	c = 0
	i = 0
	ans = 0
	while i < n:
		f = 0
		if c == k or i == 0:
			if s[i] == '0':
				f = 1
				if i + k + 1 < n:
					for j in range(k + 1):
						if s[i + j] == '1':
							f = 0
							break
				else:
					for j in range(n - i):
						if s[i + j] == '1':
							f = 0
							break
		if s[i] == '0':
			c += 1
		else:
			c = 0
		if f == 1:
			ans += 1
			c = k
			i += k
		i += 1
	print(ans)


n = int(input())
for i in range(n):
	(l, k) = [int(x) for x in input().split(' ')]
	restaurant = input()
	sat = k
	enough = 2 * k + 1
	res = 0
	for place in restaurant:
		if place == '0':
			sat += 1
		else:
			sat = 0
		if sat == enough:
			res += 1
			sat -= k + 1
	if sat + k >= enough:
		res += 1
	print(res)


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = list(input())
	if s.count('1') == 0:
		ans = 1 + (n - 1) // (k + 1)
		print(ans)
		continue
	if s.count('0') == 0:
		print(0)
		continue
	gap = ans = 0
	flag = False
	for i in s:
		if i == '1':
			if flag == False:
				c = gap // (k + 1)
				ans += c
				gap = 0
				flag = True
				continue
			gap += 1
			c = gap // (k + 1)
			if c > 1:
				ans += c - 1
			gap = 0
		else:
			gap += 1
	c = gap // (k + 1)
	ans += c
	print(ans)


for test in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	last = -1
	all_count = 0
	for i in range(n):
		if s[i] == '1':
			if last != -1:
				all_count += (i - last) // (k + 1) - 1
			else:
				all_count += i // (k + 1)
			last = i
	if last == -1:
		all_count += (n + k) // (k + 1)
	elif (n - last) // (k + 1) > 0:
		all_count += (n - last + k) // (k + 1) - 1
	print(all_count)


import math
t = int(input())
for a0 in range(0, t):
	(n, k) = list(map(int, input().split(' ')))
	s = input()
	ar = []
	ar.append(-k - 1)
	for i in range(0, n):
		if s[i] == '1':
			ar.append(i)
	ar.append(n + k)
	ans = 0
	for i in range(0, len(ar) - 1):
		if ar[i + 1] - ar[i] - 1 - 2 * k > 0:
			ans += math.ceil((ar[i + 1] - ar[i] - 1 - 2 * k) / (k + 1))
	print(ans)


import sys
sys.setrecursionlimit(10000)
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = input()
	occ = []
	empty = []
	for (ind, i) in enumerate(s):
		if i == '1':
			occ.append(ind)
		else:
			empty.append(ind)
	ans = 0
	for seat in range(1, len(occ)):
		x = (occ[seat] - occ[seat - 1] - 1 - k) // (k + 1)
		if x < 0:
			x == 0
		ans += x
	if len(occ) > 0:
		ans += occ[0] // (k + 1)
		ans += (n - occ[-1] - 1) // (k + 1)
	else:
		ans += 1
		ans += (n - 1) // (k + 1)
	print(ans)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s = '0' * k + s.strip() + '0' * k
	r = 0
	t = 0
	for c in s:
		if c == '1':
			t = 0
		else:
			t += 1
			if t == 2 * k + 1:
				r += 1
				t = k
	print(r)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	table = dict()
	(n, k) = map(int, sys.stdin.readline().split())
	s = list(sys.stdin.readline().strip())
	temp = 0
	for i in range(n):
		if s[i] == '1':
			temp = k
		elif temp > 0:
			table[i] = 1
			temp -= 1
	temp = 0
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			temp = k
		elif temp > 0:
			table[i] = 1
			temp -= 1
	res = 0
	lock1 = -1
	for i in range(n):
		if i <= lock1:
			continue
		if i in table:
			continue
		if s[i] == '0':
			s[i] = '1'
			res += 1
			lock1 = i + k
		elif s[i] == '1':
			lock1 = i + k
	print(res)


t = int(input())
while t >= 1:
	(n, k) = [int(x) for x in input().split()]
	s = input()
	if '1' not in s:
		ans = 1
		temp = n - k - 1
		while temp > 0:
			temp -= k
			temp -= 1
			ans += 1
		print(ans)
		t -= 1
		continue
	d = [len(x) for x in s.split('1')]
	ans = 0
	d = [x for x in d if x > 0]
	if s[0] == '0':
		if d[0] >= k + 1:
			ans += 1
			d[0] -= 1
	if s[-1] == '0' and (s[0] == '1' or len(d) > 1):
		if d[-1] >= k + 1:
			ans += 1
			d[-1] -= 1
	for i in d:
		if i != 0:
			temp = i
			while temp >= k:
				temp -= k
				temp -= 1
				if temp >= k:
					ans += 1
	print(ans)
	t -= 1


def calc(n, x, s):
	s = list(map(int, list(s)))
	count = 0
	arr = [0 for i in range(n)]
	j = n - 1
	var = -1
	while j >= 0:
		if s[j] == 1:
			var = j
		if s[j] == 0:
			arr[j] = var
		j -= 1
	i = 0
	while i < n:
		if s[i] == 0:
			if arr[i] == -1 or arr[i] - i - 1 >= x:
				count += 1
				i += x + 1
			else:
				i += 1
		else:
			i += x + 1
	print(count)
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	s = input()
	calc(n, x, s)


T = int(input())
for i in range(0, T):
	(n, K) = list(map(int, input().split()))
	A = str(input())
	l = len(A)
	k = 0
	ans = 0
	while k < l:
		if A[k] == '0':
			flag = 0
			if k == 0:
				flag += 1
			leng = 0
			while k < l and A[k] != '1':
				leng += 1
				k += 1
			if k == l:
				flag += 1
			if flag == 0:
				leng -= 2 * K
			elif flag == 1:
				leng -= K
			if leng > 0:
				if leng % (K + 1) == 0:
					ans += int(leng / (K + 1))
				else:
					ans += int(leng / (K + 1)) + 1
		else:
			k += 1
	print(ans)


test = int(input())
test_arr = []
for _ in range(test):
	(n, k) = map(int, input().split())
	string = str(input())
	i = 0
	main_count = 0
	while i < n:
		if string[i] == '1':
			i += k + 1
		else:
			count = 0
			i += 1
			flag = 0
			while count < k and i < n:
				if string[i] == '1':
					flag = 1
					break
				count += 1
				i += 1
			if flag == 0:
				main_count += 1
	test_arr.append(main_count)
for t in test_arr:
	print(t)


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)


a = int(input())
ans = ''
for i in range(a):
	(n, k) = map(int, input().split())
	A = input()
	A = [int(A[i]) for i in range(len(A))]
	I = A
	A = [0] * (k + 1) + A + [0] * (k + 1)
	n += 2 * (k + 1)
	(left, right, bee) = (0, 0, 0)
	it = 0
	while it < n and A[it] != 1:
		it += 1
	right = it
	while right <= n:
		while right - left + 1 >= 2 * k + 3:
			left += k + 1
			A[left] = 1
		left = right
		right += 1
		while right < n and A[right] != 1:
			right += 1
	F = A[k + 1:-k - 1]
	ans += str(sum(F) - sum(I)) + '\n'
print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ind = []
	for i in range(n):
		if s[i] == '1':
			ind.append(i)
	m = len(ind)
	(i, j) = (0, 0)
	count = 0
	while i < n:
		if s[i] == '0':
			if j >= m or ind[j] > i + k:
				count += 1
				i += k + 1
			else:
				i = ind[j] + (k + 1)
				j += 1
		else:
			i += k + 1
	print(count)


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


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, list(input())))
	i = 0
	while i < n:
		if a[i] == 1:
			for j in range(i - k, i + k + 1):
				if j >= 0 and j < n:
					a[j] = 1
			i += k + 1
		else:
			i += 1
	i = 0
	count = 0
	while i < n:
		if a[i] == 0:
			count += 1
			for j in range(i - k, i + k + 1):
				if j >= 0 and j < n:
					a[j] = 1
			i += k + 1
		else:
			i += 1
	print(count)


def solve(n, k, s):

	def cal(l, r, k):
		if l > r:
			return 0
		n = r - l + 1
		return n // k + (n % k != 0)
	p = []
	ans = 0
	for (i, v) in enumerate(s):
		if v == '1':
			p.append(i)
	if not p:
		return cal(0, n - 1, k)
	for i in range(len(p) - 1):
		ans += cal(p[i] + k, p[i + 1] - k, k)
	ans += cal(0, p[0] - k, k) + cal(p[-1] + k, n - 1, k)
	return ans

def main():
	inp = lambda : [int(x) for x in input().split()]
	inn = lambda : int(input())
	t = inn()
	for _ in range(t):
		(n, k) = inp()
		s = input()
		print(solve(n, k + 1, s))
main()


import sys
import math
from collections import *

def get_ints():
	return map(int, input().split())

def get_list():
	return list(get_ints())

def printspx(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
MODPRIME = int(1000000000.0 + 7)
BABYMODPR = 998244353
MAXN = int(100000.0)
for _testcases_ in range(int(input())):
	(n, k) = get_ints()
	s = input()
	li = []
	for (i, v) in enumerate(s):
		if v == '1':
			li.append(i)
	prev = -float('inf')
	try:
		nxt = li[0]
	except:
		nxt = float('inf')
	i = j = ans = 0
	while i < n:
		if i - prev > k and nxt - i > k:
			ans += 1
			prev = i
		if i >= nxt:
			prev = nxt
			j += 1
			try:
				nxt = li[j]
			except:
				nxt = float('inf')
		i += 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input()))
	l1 = [-1]
	for j in range(n):
		if l[j] == 1:
			l1.append(j)
	l1.append(n)
	if len(l1) == 2:
		a = n // (k + 1)
		if n % (k + 1):
			a += 1
		print(a)
	else:
		ans = 0
		for j in range(len(l1) - 1):
			if j == 0:
				if l1[j + 1] - l1[j] - k > 1:
					a = l1[j + 1] - k - 1
					c = a + 1
					x = c // (k + 1)
					if c % (k + 1):
						x += 1
					ans += x
			elif l1[j + 1] == n:
				if l1[j + 1] - l1[j] - k > 1:
					a = l1[j] + k + 1
					c = n - a
					x = c // (k + 1)
					if c % (k + 1):
						x += 1
					ans += x
			elif l1[j + 1] - l1[j] >= 2 * k + 1:
				a = l1[j] + k + 1
				b = l1[j + 1] - k - 1
				c = b - a + 1
				x = c // (k + 1)
				if c % (k + 1):
					x += 1
				ans += x
		print(ans)


test = int(input())
for _ in range(test):
	(n, k) = map(int, input().split())
	arr = list(input())
	last = -1
	total = 0
	for i in range(n):
		if arr[i] == '1':
			if last == -1:
				total += (i - 0) // (k + 1)
			else:
				av = i - last - 1
				if av != 0:
					total += (av - k) // (k + 1)
			last = i
	if last == -1:
		print(1 + (n - 1) // (k + 1))
	else:
		total += (n - 1 - last) // (k + 1)
		print(total)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(input())
	if '1' in a:
		p = a.index('1')
		s = max(0, p // (k + 1))
		for j in range(p + 1, n):
			if a[j] == '1':
				s += max(0, (j - p - 1 - k) // (k + 1))
				p = j
		s += max(0, (n - p - 1) // (k + 1))
		print(s)
	elif n == k:
		print(1)
	else:
		print((n + k) // (k + 1))


def main():
	for _ in range(int(input())):
		(n, k) = tuple(map(int, input().split()))
		a = input()
		l = []
		if n == 1:
			print(a.count('0'))
			continue
		elif n <= k and a.count('1') == 0:
			print(1)
			continue
		for i in range(n):
			if a[i] == '1':
				l += [i]
		count = 0
		yo = 0
		hehe = 0
		if 0 not in l:
			yo = 'iamtefi'
			l += [0]
		if n - 1 not in l:
			hehe = 'iamtefu'
			l += [n - 1]
		l.sort()
		for i in range(1, len(l)):
			set1 = 1
			set2 = 1
			if i - 1 == 0 and yo == 'iamtefi':
				set1 = 0
			if i == len(l) - 1 and hehe == 'iamtefu':
				set2 = 0
			m = (l[i] - l[i - 1]) // (1 + k) - (set1 + set2) + 1
			if m > 0:
				count += m
		print(count)
main()


t = int(input())
for test in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr = input()
	count = 0
	nz = 0
	one = 0
	for i in range(n):
		if arr[i] == '0':
			nz += 1
		else:
			if one == 0:
				count += nz // (k + 1)
				one = 1
			elif nz % (k + 1) >= k:
				count += nz // (k + 1)
			else:
				count += nz // (k + 1)
				count -= 1
			nz = 0
	count += nz // (k + 1)
	if nz == n:
		if count == 0:
			count = 1
		else:
			temp = nz / (k + 1)
			if nz % (k + 1) == 0:
				count = nz // (k + 1)
			else:
				count = nz // (k + 1) + 1
	print(count)


import sys
debug = True
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = int(input())
for t in range(test_count):
	(n, k) = invr()
	s = insr()
	indexes = list()
	for i in range(n):
		if s[i] == '1':
			indexes.append(i + 1)
	last = 0
	count = 0
	if len(indexes) == 0:
		count = 1 + (n - 1) // (k + 1)
	for i in range(len(indexes)):
		x = indexes[i]
		if i == 0:
			if x > k:
				count += (x - 1) // (k + 1)
		else:
			dist = x - last - 1
			if dist > k:
				count += (dist + 1) // (k + 1) - 1
		if i == len(indexes) - 1:
			dist = n - x
			if dist > k:
				count += dist // (k + 1)
		last = x
	print(count)


import itertools
T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	s = input().strip()
	a = [0] * n
	for i in range(n):
		if s[i] == '1':
			(l, r) = (max(i - k, 0), i + k + 1)
			a[l] += 1
			if r < n:
				a[r] -= 1
	a = list(itertools.accumulate(a))
	ans = 0
	i = 0
	while i < n:
		if a[i] == 0:
			ans += 1
			i += k + 1
		else:
			i += 1
	print(ans)


import math
t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	list1 = list(input())
	i = 0
	ans = []
	while i < n:
		if list1[i] == '0':
			start = i
			i += 1
			while i < n and list1[i] == '0':
				i += 1
			if i < n:
				ans.append([start, i - k - 1])
				i += k + 1
			else:
				ans.append([start, i - 1])
		else:
			i += k + 1
	count = 0
	for i in range(len(ans)):
		count += math.ceil((ans[i][1] - ans[i][0] + 1) / (k + 1))
	print(count)
	t -= 1


from collections import deque
rr = lambda : input()
rri = lambda : int(input())
rrm = lambda : list(map(int, input().split()))
INF = float('inf')

def solve(N, K, arr):
	left = [None] * n
	right = [None] * n
	f = INF
	for i in range(n):
		if arr[i] == '1':
			f = 0
		else:
			f += 1
		left[i] = f
	f = INF
	for i in range(n - 1, -1, -1):
		if arr[i] == '1':
			f = 0
		else:
			f += 1
		right[i] = f
	dp = [0 for _ in range(n)]
	dp[0] = 1 if min(left[i], right[i]) > K else 0
	amt = 0
	for i in range(1, n):
		if min(left[i], right[i]) > K and i - K - 1 >= 0:
			dp[i] = max(dp[-1], dp[i - K - 1] + 1)
		else:
			dp[i] = dp[i - 1]
	return dp[-1]
t = int(input())
for _ in range(t):
	(n, k) = rrm()
	arr = list(input())
	print(solve(n, k, arr))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = str(input())
	limit = k
	count = 0
	for i in range(n):
		if s[i] == '0':
			limit += 1
		else:
			limit = 0
		if limit == 2 * k + 1:
			count += 1
			limit = k
	if limit >= k + 1:
		count += 1
	print(count)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	delta = 0
	bool = 0
	ans = 0
	var = 0
	for i in s:
		if i == '0':
			delta += 1
			var = 0
		if i == '1':
			if bool == 0:
				ans += delta // (k + 1)
				bool = 1
			else:
				ans += (delta - k) // (k + 1)
			var = 1
			delta = 0
	if var == 0:
		ans += delta // (k + 1)
	if bool == 0:
		ans = (delta + k) // (k + 1)
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	tables = [0] * n
	for i in range(len(s)):
		if s[i] == '1':
			for j in range(max(0, i - k), min(n, i + k + 1)):
				tables[j] = 1
	i = 0
	ans = 0
	while i <= n - 1:
		if tables[i] == 0:
			ans += 1
			i += k
		i += 1
	print(ans)


def f(n, k):
	if n <= 0:
		return 0
	if n % (k + 1) == 0:
		return n // (k + 1)
	else:
		return n // (k + 1) + 1

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = list(map(int, input().split()))
		s = input().split('1')
		l = len(s)
		ans = 0
		if l > 1:
			ans += f(len(s[0]) - k, k)
			for i in range(1, l - 1):
				ans += f(len(s[i]) - 2 * k, k)
			ans += f(len(s[l - 1]) - k, k)
		else:
			ans = f(len(s[0]), k)
		print(ans)
main()


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict as dd, deque as dq

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		s = input()
		ar = dq()
		for i in range(n):
			if s[i] == '1':
				ar.append(i)
		al = len(ar)
		ans = 0
		if al == 0:
			ans = 1 + (n - 1) // (k + 1)
		else:
			ans = ar[0] // (k + 1) + max(0, n - ar[-1] - 1) // (k + 1)
			if al > 1:
				for i in range(al - 1):
					ans += max(ar[i + 1] - ar[i] - 1 - k, 0) // (k + 1)
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	a = input()
	total = 0
	temp = [i for (i, x) in enumerate(a) if x == '1']
	if len(temp) > 1:
		total += temp[0] // (k + 1)
		total += (len(a) - temp[-1] - 1) // (k + 1)
		for i in range(len(temp) - 1):
			if temp[i + 1] - temp[i] - 1 >= 2 * k + 1:
				total += 1
			if temp[i + 1] - temp[i] - 1 > 2 * k + 1:
				total += (temp[i + 1] - temp[i] - 1 - (2 * k + 1)) // (k + 1)
	elif len(temp) == 1:
		total += temp[0] // (k + 1)
		total += (len(a) - temp[0] - 1) // (k + 1)
	else:
		total += math.ceil(len(a) / (k + 1))
	print(total)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	inf = [0] * n
	lst = 0
	for i in range(n):
		if s[i] == '1':
			for j in range(max(lst, i - k), min(i + k + 1, n)):
				inf[j] = 1
			lst = i + k
			i = i + k
	lst = -1
	for i in range(n):
		if inf[i] == 0:
			lst = i
			break
	if lst == -1:
		print(0)
	else:
		cnt = 1
		for i in range(lst + 1, n):
			if inf[i] == 0 and i > lst + k:
				cnt += 1
				lst = i
		print(cnt)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = str(input())
	a = [int(i) for i in s]
	c = 0
	p1 = 0
	if a[0] == 0:
		c += 1
	for i in range(1, n):
		if a[i] == 1:
			if i - p1 - k <= 0:
				c -= 1
			p1 = i
		elif i - p1 - k > 0:
			c += 1
			p1 = i
	print(c)


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, k, s):
	s = ('0' * k + s + '0' * k).split('1')
	ans = 0
	for i in s:
		ans += (len(i) - k) // (k + 1)
	print(ans)
for _ in range(int(input())):
	(n, k) = get_int()
	s = str(input())[:-1]
	solve(n, k, s)


from collections import Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	cnt = 0
	var = 0
	for i in range(n):
		if s[i] == '0':
			var += 1
			if var > k:
				if i == n - 1:
					cnt += 1
					break
				elif i + k <= n and s[i + 1:i + k + 1] == '0' * k:
					cnt += 1
					var = 0
				elif i + k > n and s[i + 1:] == '0' * (n - (i + 1)):
					cnt += 1
					break
			elif i == 0:
				if n - (i + 1) > k:
					if s[i:i + k + 1] == '0' * (k + 1):
						cnt += 1
						var = 0
				elif s[i:] == '0' * (n - i):
					cnt += 1
					var = 0
					break
		else:
			var = 0
	print(cnt)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, k) = value()
	table = list(input())
	if len(set(table)) == 1 and table[0] == '0':
		ans = 0
		for i in range(0, n, k + 1):
			ans += 1
		print(ans)
		continue
	ind = table.index('1')
	i = ind
	ans = 0
	while i < n:
		if table[i] == '1':
			start = i
			c = 0
			i += 1
			while i < n and table[i] == '0':
				i += 1
				c += 1
			if i == n:
				ans += c // (k + 1)
			else:
				end = i - k
				possible = (end - start - 1) // (k + 1)
				if end > start:
					ans += possible
		else:
			i += 1
	for i in range(ind - k - 1, -1, -k - 1):
		ans += 1
	print(ans)


def solve(tables, distance, seq):
	index = 0
	ans = 0
	while index < tables:
		if seq[index] == '0':
			makeEmpty = index + distance
			isEmpty = True
			while index <= makeEmpty and index < tables:
				if seq[index] == '1':
					isEmpty = False
					break
				index += 1
			if isEmpty:
				ans += 1
		else:
			index += distance + 1
	return ans
for x in range(int(input())):
	(t, d) = list(map(int, input().split()))
	seq = list(input())
	print(solve(t, d, seq))


import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi, log
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque
from functools import cmp_to_key, reduce
INT_MAX = sys.maxsize
INT_MIN = -sys.maxsize - 1
mod = 1000000007
ch = 'abcdefghijklmnopqrstuvwxyz'
lcm = lambda a, b: a * b // gcd(a, b)
setbit = lambda x: bin(x)[2:].count('1')

def solve():
	T = int(sys.stdin.readline())
	for _ in range(T):
		(n, k) = map(int, sys.stdin.readline().split())
		s = str(sys.stdin.readline()).replace('\n', '')
		s = list(s)
		dist = 2 * k + 1
		if '1' in s:
			ans = 0
			one = []
			for i in range(n):
				if s[i] == '1':
					one.append(i)
			if one[0] != 0:
				ans += (one[0] - 0) // (k + 1)
			if one[-1] != n - 1:
				ans += (n - 1 - one[-1]) // (k + 1)
			for i in range(len(one) - 1):
				if one[i + 1] - one[i] > k:
					ans += (one[i + 1] - one[i]) // (k + 1) - 1
			print(ans)
		else:
			i = 0
			c = 0
			while i < n:
				c += 1
				i += k + 1
			print(c)
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
solve()


import bisect
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	dominated = [0] * (n + 1)
	sitting = [-k]
	for (i, v) in enumerate(s):
		if v == '1':
			dominated[i + 1] = 1
			sitting.append(i + 1)
	sitting.append(n + k + 1)
	ans = 0
	for i in range(1, n + 1):
		if dominated[i]:
			continue
		ind = bisect.bisect_left(sitting, i)
		if abs(sitting[ind - 1] - i) > k and abs(sitting[ind] - i) > k:
			ans += 1
			bisect.insort_left(sitting, i)
	print(ans)


from functools import reduce
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	(r, i) = (0, 0)
	while i < n:
		if s[i] == '1':
			i += k + 1
		elif i + k + 1 < n:
			if s[i + 1:i + k + 1] == '0' * k:
				r += 1
				i += k + 1
			else:
				i += 1
		else:
			if s[i + 1:n] == '0' * (n - i - 1):
				r += 1
			break
	print(r)


import sys

def solve(n: int, k: int, s: str) -> str:
	text = s.strip()
	result = 0
	available = text.split('1')
	try:
		for (i, av) in enumerate(available):
			if len(av) < 1:
				continue
			if i == 0:
				av = '0' * k + av
			if i == len(available) - 1:
				av = av + '0' * k
				pass
			l = k + 1
			remainder = len(av) % l
			if remainder < k:
				result += len(av) // l - 1
			else:
				result += len(av) // l
	except IndexError:
		pass
	return result
N = int(sys.stdin.readline())
for i in range(N):
	t = sys.stdin.readline()
	(n, k) = t.strip().split()
	s = sys.stdin.readline()
	print(solve(int(n), int(k), s))


from math import *

def _in():
	return [int(x) for x in input().split(' ')]

def main():
	(n, k) = _in()
	s = input().split('1')
	ans = 0
	if len(s) == 1:
		ans = max(0, len(s[0]) - 1) // (k + 1) + 1
	else:
		ans = len(s[0]) // (k + 1)
	if len(s) > 1:
		ans = ans + len(s[-1]) // (k + 1)
	for i in range(1, len(s) - 1):
		ans = ans + max(0, len(s[i]) - k) // (k + 1)
	print(ans)
tt = 1
tt = int(input())
for _ in range(tt):
	main()


import sys
for _ in range(int(input())):
	(n, k) = input().split(' ')
	(n, k) = (int(n), int(k))
	string = list(input())
	c = sys.maxsize
	n = len(string)
	sarr = [sys.maxsize] * (n + 1)
	for i in range(n - 1, -1, -1):
		if string[i] == '0':
			sarr[i] = c
			c += 1
		else:
			c = 1
			sarr[i] = 0
	c = sys.maxsize
	ans = 0
	for i in range(n):
		if string[i] == '1':
			c = 0
		else:
			c = c + 1
			if c > k and sarr[i + 1] >= k:
				ans += 1
				c = 0
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	cnt = 0
	l = []
	for c in s:
		if c == '0':
			cnt += 1
		else:
			l.append(cnt)
			cnt = 0
	l.append(cnt)
	ans = 0
	if len(l) == 1:
		ans = max(0, (l[0] - 1) // (k + 1) + 1)
	else:
		for i in range(len(l)):
			if 0 < i < len(l) - 1:
				l[i] -= k * 2
			else:
				l[i] -= k
			ans += max(0, (l[i] - 1) // (k + 1) + 1)
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	pre_one = False
	i = 0
	j = 0
	ans = 0
	if n == k:
		if s.count('1') == 0:
			print(1)
		else:
			print(0)
	else:
		while i < n:
			pre_one = False
			if s[i] == '1':
				i += k + 1
			elif s[i] == '0':
				pre_one = True
				j = 1
				i += 1
				while j <= k:
					if i < n:
						if s[i] == '1':
							pre_one = False
							i += k + 1
							break
						j += 1
						i += 1
					else:
						break
			if pre_one:
				ans += 1
		print(ans)


def main():
	T = int(input())
	for _ in range(T):
		(N, K) = map(int, input().split())
		S = list(input())
		onesPos = []
		for i in range(N):
			if S[i] == '1':
				onesPos.append(i)
		ans = 0
		if len(onesPos) == 0:
			S[0] = '1'
			ans += 1
			for i in range(K + 1, N, K + 1):
				S[i] = '1'
				ans += 1
		else:
			for i in range(onesPos[0] - K - 1, -1, -(K + 1)):
				S[i] = '1'
				ans += 1
			for i in range(len(onesPos) - 1):
				if onesPos[i + 1] - onesPos[i] - 1 >= 2 * K + 1:
					if (onesPos[i + 1] - onesPos[i] - 1) % 2 != 0:
						for k in range(onesPos[i] + K + 1, onesPos[i + 1], K + 1):
							if onesPos[i + 1] - k >= K + 1:
								S[k] = '1'
								ans += 1
					else:
						for k in range(onesPos[i] + K + 1, onesPos[i + 1] - 1, K + 1):
							if onesPos[i + 1] - k >= K + 1:
								S[k] = '1'
								ans += 1
			for i in range(onesPos[-1] + K + 1, N, K + 1):
				ans += 1
				S[i] = '1'
		print(ans)
main()


T = int(input())
for isc in range(T):
	(n, k) = map(int, input().split())
	s = input()
	if not '1' in s:
		l = len(s)
		u = l // (k + 1)
		if (k + 1) * u < l:
			u += 1
		print(u)
		continue
	sl = s.split('1')
	ret = 0
	for i in range(len(sl)):
		l = len(sl[i])
		if i == 0:
			ret += l // (k + 1)
		elif i == len(sl) - 1:
			ret += l // (k + 1)
		else:
			ret += (l + 1) // (k + 1) - 1
	print(ret)


t = int(input())

def solve(a, k):
	ans = 0
	dist = 0
	for i in range(len(a)):
		if a[i] == '0':
			if dist > k or i == 0:
				ans += 1
				if i != 0:
					dist = 0
			dist += 1
		else:
			if dist <= k and ans > 0:
				ans -= 1
			dist = 1
	return ans if ans > 0 else 0
while t > 0:
	l = [int(x) for x in input().split()]
	(n, k) = (l[0], l[1])
	a = input()
	print(solve(a, k))
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	tables = input()
	total = 0
	if n == k:
		print(total) if '1' in tables else print(total + 1)
	elif '1' in tables:
		loc = tables.index('1')
		forw = tables[loc:]
		back = tables[loc::-1]
		it = 0
		for f in range(len(forw)):
			if it % (k + 1) == 0 and it != 0 and (forw[f] != '1') and ('1' not in forw[f + 1:f + k + 1]):
				total += 1
				it += 1
			elif forw[f] == '1':
				it = 1
			else:
				it += 1
		it = 0
		for b in range(len(back)):
			if it % (k + 1) == 0 and it != 0 and (back[b] != '1') and ('1' not in back[b + 1:b + k + 1]):
				total += 1
				it += 1
			elif back[b] == '1':
				it = 1
			else:
				it += 1
		print(total)
	else:
		for i in range(0, n, k + 1):
			if i + k + 1 > n:
				total += 1
			elif tables[i] == '0':
				total += 1
		print(total)


for ii in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	a = []
	for i in range(n):
		if s[i] == '1':
			a.append(i + 1)
	if a == []:
		print((len(s) - 1) // (k + 1) + 1)
	else:
		ans = 0
		for i in range(len(a) - 1):
			x = a[i + 1] - a[i] - 1
			ans += max(0, (x - 2 * k - 1) // (k + 1) + 1)
		ans += max(0, (a[0] - k - 2) // (k + 1) + 1)
		ans += max(0, (n - a[-1] - k - 1) // (k + 1) + 1)
		print(ans)


def checkTable(t, k, i):
	j = 1
	while j <= k:
		if i + j < len(t):
			if t[i + j] == '1':
				return (False, j)
		if i - j > -1:
			if t[i - j] == '1':
				return (False, 1)
		j += 1
	return (True, k)

def solve(n, k, t):
	i = 0
	count = 0
	while i < n:
		if t[i] == '0':
			(occ_state, inc) = checkTable(t, k, i)
			if occ_state:
				count += 1
				t[i] = '1'
				continue
			i += inc
		else:
			i += k
	print(count)
t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	t = list(input())
	solve(n, k, t)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	prefix = [0] * n
	cnt = 0
	for i in range(n):
		if s[i] == '0':
			cnt += 1
		prefix[i] = cnt
	ans = 0
	i = 0
	while i < n:
		if s[i] == '0':
			flag1 = False
			flag2 = False
			if i - k - 1 >= 0 and prefix[i - 1] - prefix[i - k - 1] == k:
				flag1 = True
			elif i == 0:
				flag1 = True
			elif i - k - 1 < 0 and prefix[i - 1] == i:
				flag1 = True
			if i + k < n and prefix[i + k] - prefix[i] == k:
				flag2 = True
			elif i + k >= n and prefix[n - 1] - prefix[i] == n - i - 1:
				flag2 = True
			if flag2 and flag1:
				ans += 1
				i += k + 1
			else:
				i += 1
		else:
			i += 1
	print(ans)


def solve(n, k, s):
	ind = [0]
	for i in range(n):
		if s[i] == '1':
			ind.append(i + 1)
	ind.append(n + 1)
	if len(ind) == 2:
		if n % (k + 1) == 0:
			return n // (k + 1)
		else:
			return n // (k + 1) + 1
	else:
		ans = 0
		for i in range(len(ind) - 1):
			if i == 0:
				ans += int((ind[1] - 1) / (k + 1))
				continue
			elif i == len(ind) - 2:
				ans += int((n - ind[i]) / (k + 1))
				continue
			dif = ind[i + 1] - ind[i] - 1
			if dif < 2 * k + 1:
				continue
			else:
				ans += int((dif + 1) // (k + 1)) - 1
		return ans
t = int(input())
for i in range(t):
	(n, k) = tuple(map(int, input().split()))
	s = input()
	print(solve(n, k, s))


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	l = str(input())
	g = list()
	g.append(-k - 1)
	cnt = 0
	for i in range(n):
		if l[i] == '1':
			g.append(i)
	g.append(n + k)
	a = len(g)
	for j in range(a - 1):
		if g[j + 1] - g[j] - 1 > 2 * k:
			t = g[j + 1] - g[j] - 1 - 2 * k
			if t % (k + 1) == 0:
				cnt = cnt + t // (k + 1)
			else:
				cnt = cnt + (1 + t // (k + 1))
	print(cnt)


def solve():
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	a = list(input())
	b = []
	num = 0
	ans = 0
	for i in range(n):
		if a[i] == '1':
			b.append(i)
			num += 1
	if num == 0:
		if n % (k + 1) == 0:
			ans = n // (k + 1)
		else:
			ans = n // (k + 1) + 1
	else:
		ans += b[0] // (k + 1)
		for i in range(num - 1):
			for j in range(b[i], b[i + 1], k + 1):
				if j == b[i]:
					continue
				elif b[i + 1] - j - 1 < k:
					continue
				else:
					ans += 1
		ans += (n - b[num - 1] - 1) // (k + 1)
	print(ans)
t = eval(input())
for i in range(t):
	solve()


test = int(input())
for i in range(test):
	(n, k) = [int(i) for i in input().split()]
	binary = input()
	suff = [float('inf')] * n
	suff[-1] = 0 if binary[-1] == '1' else float('inf')
	for j in range(len(binary) - 2, -1, -1):
		if binary[j] == '1':
			suff[j] = 0
		else:
			suff[j] = 1 + suff[j + 1]
	last = -1
	ans = 0
	for i in range(len(binary)):
		if binary[i] == '0':
			if last != -1:
				if i - last > k and suff[i] > k:
					ans += 1
					last = i
			elif suff[i] > k:
				ans += 1
				last = i
		else:
			last = i
	print(ans)


t = int(input(''))
while t > 0:
	(n, k) = map(int, input().split())
	s = input('')
	gaps = []
	gap_count = 0
	for i in s:
		if i == '1':
			gaps.append(gap_count)
			gap_count = 0
		else:
			gap_count += 1
	if s[-1] == '0':
		gaps.append(gap_count)
	else:
		gaps.append(0)
	answer = 0
	for j in range(len(gaps)):
		if j == 0 or j == len(gaps) - 1:
			answer += gaps[j] // (k + 1)
		elif gaps[j] >= 2 * k + 1:
			answer += 1
			answer += (gaps[j] - 2 * k - 1) // (k + 1)
	if '1' not in s:
		if k >= n:
			answer = 1
		elif n % (k + 1) != 0:
			answer += 1
	print(answer)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lst = ['0'] * k + list(input()) + ['0'] * k
	(a, c) = (0, 0)
	i = 0
	while i <= n + k * 2 - 1:
		if lst[i] == '0':
			a = a + 1
			if a == k * 2 + 1:
				a = k
				c = c + 1
		else:
			a = 0
		i = i + 1
	print(c)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	a = []
	st = -1
	ans = 0
	for i in range(n):
		if s[i] == '1':
			st = i
			break
	if st != -1:
		ans += st // (k + 1)
		for i in range(st, n):
			if s[i] == '1':
				a.append(i - st - 1)
				st = i
		if st != n - 1:
			ans += (n - 1 - st) // (k + 1)
		for i in a:
			i -= k
			if i > 0:
				ans += i // (k + 1)
		print(ans)
	elif n % (k + 1) == 0:
		print(n // (k + 1))
	else:
		print(n // (k + 1) + 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


import math
n = int(input())
lst = []
for _ in range(n):
	(x, k) = map(int, input().split())
	lst1 = []
	sum = 0
	str1 = input()
	for i in range(x):
		if str1[i] == '1':
			lst1.append(i + 1)
	if len(lst1) == 0:
		sum += math.ceil(x / (k + 1))
	elif len(lst1) == 1:
		sum += int((lst1[0] - 1) / (k + 1))
		sum += int((x - lst1[0]) / (k + 1))
	else:
		y = len(lst1)
		for i in range(len(lst1) - 1):
			sum += int((lst1[i + 1] - lst1[i]) / (k + 1)) - 1
		sum += int((lst1[0] - 1) / (k + 1))
		sum += int((x - lst1[y - 1]) / (k + 1))
	lst.append(sum)
for val in lst:
	print(val)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = input()
	c = 0
	cnt = k
	for i in range(n):
		if x[i] == '0':
			cnt += 1
		else:
			cnt = 0
		if cnt == 2 * k + 1:
			c += 1
			cnt = k
	if cnt >= k + 1:
		c += 1
	print(c)


import sys
import os
import heapq
import math
try:
	path = './file/input.txt'
	if os.path.exists(path):
		sys.stdin = open(path, 'r')
except:
	pass
t = int(input())

def printd(value):
	pass

def case():
	arr = list(map(int, input().split(' ')))
	(n, k) = (arr[0], arr[1])
	arr = input()
	startOne = False
	length = 0
	result = 0
	for value in arr:
		if value == '1':
			length = max(0, length - k)
			if startOne:
				length = max(0, length - k)
			result += length // (k + 1) + (1 if length % (k + 1) > 0 else 0)
			startOne = True
			length = 0
		else:
			length += 1
	if startOne:
		length = max(0, length - k)
	result += length // (k + 1) + (1 if length % (k + 1) > 0 else 0)
	print(result)
for _ in range(t):
	case()


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	S = [int(v) for v in input()]
	ans = 0
	seq = 0
	D = [0] * N
	seq = 0
	for i in range(N):
		if S[i] == 1:
			D[i] = 1
			seq = K
		elif seq > 0:
			seq -= 1
			D[i] = 1
		else:
			pass
	for i in reversed(range(N)):
		if S[i] == 1:
			D[i] = 1
			seq = K
		elif seq > 0:
			seq -= 1
			D[i] = 1
		else:
			pass
	D.append(1)
	seq = 0
	ans = 0
	D = ''.join(map(str, D))
	for seq in D.split('1'):
		if len(seq) == 0:
			pass
		else:
			ans += (len(seq) - 1) // (K + 1) + 1
	print(ans)


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	cnt = []
	cur = 0
	ans = 0
	for (i, c) in enumerate(s):
		if c == '0':
			cur += 1
		elif cur != 0:
			cnt.append(cur)
			cur = 0
	if cur != 0:
		cnt.append(cur)
	if s[0] == '0' and s[-1] == '0' and (len(cnt) == 1):
		print(ceil(cnt[0] / (k + 1)))
		continue
	if s[0] == '0':
		cnt[0] = max(0, cnt[0] - k)
		ans += ceil(cnt[0] / (k + 1))
		cnt.pop(0)
	if s[-1] == '0':
		cnt[-1] = max(0, cnt[-1] - k)
		ans += ceil(cnt[-1] / (k + 1))
		cnt.pop(-1)
	for c in cnt:
		ans += ceil(max(0, c - k * 2) / (k + 1))
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	i = 0
	Ans = 0
	while i < n:
		if s[i] == '1':
			i += k + 1
			f = 1
		else:
			j = i + 1
			flag = 0
			while j < n and j < i + k + 1:
				if s[j] == '1':
					flag = 1
					i = j
					break
				j += 1
			if flag == 0:
				s[i] = '1'
				i += k + 1
				Ans += 1
				f = 1
	print(Ans)


from sys import stdin, stdout
import math

def solve():
	(n, k) = map(int, input().split())
	l = list(input())
	lst = []
	for i in range(n):
		if l[i] == '1':
			lst.append(i)
	if len(lst) == 0:
		cnt = 0
		for i in range(0, n, k + 1):
			cnt += 1
		print(cnt)
		return
	cnt = 0
	if lst[0] > k:
		lst.insert(0, 0)
		cnt += 1
	if lst[-1] + k + 1 <= n - 1:
		lst.append(n - 1)
		cnt += 1
	for i in range(len(lst) - 1):
		for j in range(lst[i] + k + 1, lst[i + 1] - k, k + 1):
			cnt += 1
	print(cnt)
test = 1
test = int(input())
for __ in range(test):
	solve()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	w = input()
	zeroes = []
	z = 0
	res = 0
	for c in w:
		if c == '1':
			zeroes.append(z)
			z = 0
		else:
			z += 1
	zeroes.append(z)
	if len(zeroes) == 1:
		res = 1 + (len(w) - 1) // (k + 1)
	else:
		for i in range(len(zeroes)):
			if i == 0 or i == len(zeroes) - 1:
				res += zeroes[i] // (k + 1)
			elif zeroes[i] >= 2 * k + 1:
				res += 1
				p = zeroes[i] - (2 * k + 1)
				res += p // (k + 1)
	print(res)


def ans(n, k, string):
	l = list(string)
	ones = [i for i in range(n) if l[i] == '1']
	if len(ones) == 0:
		return len(string[0::k + 1])
	count = 0
	lrev = list(reversed(l))
	count += len(lrev[n - ones[0] + k::k + 1])
	for i in range(len(ones) - 1):
		if ones[i + 1] - ones[i] <= k:
			return 0
	for i in range(len(ones) - 1):
		count += len(l[ones[i]:ones[i + 1] - k:k + 1])
	count += len(l[ones[-1]::k + 1])
	return count - len(ones)
t = int(input())
L = []
for i in range(t):
	(n, k) = map(int, input().split())
	string = input()
	L.append(ans(n, k, string))
for l in L:
	print(l)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input().rstrip('\n'))
	ss = [0] * n
	for i in range(n):
		if s[i] == '1':
			ss[max(0, i - k)] += 1
			if i + k + 1 < n:
				ss[i + k + 1] -= 1
	for i in range(1, n):
		ss[i] = ss[i - 1] + ss[i]
	ans = 0
	i = 0
	while i < n:
		if ss[i] == 0:
			ans += 1
			i += k + 1
		else:
			i += 1
	print(ans)


def main():
	t = int(input())
	while t > 0:
		t = t - 1
		z = list(map(int, input('').strip().split()))
		n = z[0]
		k = z[1]
		s = input()
		a = []
		for i in range(len(s)):
			a.append(int(s[i]))
		temp = 0
		for i in range(n):
			if a[i] == 1:
				for j in range(i - k, i + k + 1):
					if j >= 0 and j < n:
						a[j] = -1
		i = 0
		while i < n:
			if a[i] == 0:
				a[i] = -2
				i = i + k + 1
			else:
				i = i + 1
		if n == 1:
			if a[0] == -2:
				print('1')
			else:
				print('0')
		else:
			ans = 0
			for i in range(n):
				if a[i] == -2:
					ans = ans + 1
			print(ans)
main()


try:
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		s = list(input())
		curr = ans = 0
		if s[0] == '0':
			ans += 1
		for i in range(curr + 1, n):
			if s[i] == '1':
				if i - curr <= k:
					ans -= 1
				curr = i
				continue
			if i - curr > k:
				s[i] = '1'
				ans += 1
				curr = i
		print(ans)
except EOFError:
	pass


def helper(n, k, s):
	(prev, count) = (-k - 1, 0)
	for i in range(n):
		if s[i] == '0':
			if i - prev - 1 >= k:
				count += 1
				prev = i
		else:
			if i - prev - 1 < k:
				count -= 1
			prev = i
	return count
for _ in range(int(input())):
	(N, K) = [int(i) for i in input().split()]
	t = input()
	print(helper(N, K, t))


def string(n, k, s):
	ans = 0
	if s[0] == '0' and '1' not in s[:k + 1]:
		s = '1' + s[1:]
		ans += 1
	for i in range(k, n):
		if s[i] == '0':
			if '1' not in s[i - k:i + k + 1]:
				ans += 1
				s = s[:i] + '1' + s[i + 1:]
	return ans
t = int(input())
array = []
for i in range(t):
	(a, b) = list(map(int, input().split(' ')))
	c = input()
	array.append([a, b, c])
for x in array:
	print(string(*x))


l = input
for p in [0] * int(l()):
	k = int(l().split()[1])
	t = '0' * k
	print(sum((max(0, len(s) - k) // (k + 1) for s in (t + l() + t).split('1'))))


from math import ceil
T = int(input())
while T:
	(n, k) = map(int, input().split())
	s = input()
	c = 0
	a = s[0]
	p = 0
	for i in range(n):
		if s[i] == '0':
			c = c + 1
		else:
			if a == '1':
				c = c - 2 * k
			else:
				c = c - k
			if c > 0:
				p = p + ceil(c / (k + 1))
			a = s[i]
			c = 0
	if a == '1':
		c = c - k
	if c > 0:
		p = p + ceil(c / (k + 1))
	if s.count('1') == 0:
		p = max(p, 1)
	print(p)
	T = T - 1


import math
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	s = list(input())
	ans = 0
	i = 0
	while i < n:
		j = i + 1
		while j < n:
			if s[j] != '1':
				j += 1
			else:
				break
		if s[i] == '1':
			left = k
		else:
			left = 0
		if j < n and s[j] == '1':
			right = k
		else:
			right = 0
		len = j - i
		if left == k:
			len -= 1
		len -= left + right
		if len > 0:
			ans += math.ceil(len / (k + 1))
		i = j
		if i >= n:
			break
	print(int(ans))


n = int(input())
for i in range(0, n):
	y = list(map(int, input().split()))
	x = str(input())
	z = y[1]
	f = list(map(int, str(x)))
	count1 = 0
	count2 = 0
	count3 = 0
	for j in range(0, y[0]):
		if f[j] == 1:
			for k in range(max(j - z, 0), min(j + z + 1, y[0])):
				if k == j:
					continue
				if f[k] != 1:
					f[k] = 2
				else:
					count1 += 1
					break
	for j in range(0, y[0]):
		if f[j] == 0:
			for k in range(max(j - z, 0), min(j + z + 1, y[0])):
				if k == j:
					continue
				if f[k] != 1:
					f[k] = 2
				else:
					count3 += 1
			if count3 == 0:
				f[j] = 1
				count2 += 1
	if count1 != 0:
		print('0')
	else:
		print(count2)


T = int(input())
for _ in range(T):
	(n, k) = list(map(int, input().split()))
	sit = input()
	last_sit = -1
	num = 0
	for (i, s) in enumerate(sit):
		if s == '1':
			if last_sit == -1:
				empties = i
				num += empties // (k + 1)
			else:
				empties = i - last_sit - 1
				num += max((empties - k) // (k + 1), 0)
			last_sit = i
		elif i == len(sit) - 1:
			if last_sit == -1:
				empties = i + 1
				num += (empties - 1) // (k + 1) + 1
			else:
				empties = i - last_sit
				num += empties // (k + 1)
	print(num)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s = '1' + '0' * k + s + '0' * k + '1'
	z = c = 0
	for i in s:
		if i == '0':
			z += 1
		if i == '1':
			z = 0
		if z == 2 * k + 1:
			c += 1
			z = k
	print(c)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	state = input()
	position = 0
	max_changes = 0
	if state[0] == '0':
		max_changes += 1
	i = 1
	while i < n:
		if state[i] == '1':
			if i - position - k <= 0:
				max_changes -= 1
			position = i
		elif i - position - k > 0:
			max_changes += 1
			position = i
		i += 1
	print(max_changes)


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	inp = input()
	indices = []
	for i in range(n):
		if inp[i] == '1':
			indices.append(i)
	if not indices:
		print(ceil(n / (k + 1)))
		continue
	cnt = 0
	for i in range(1, len(indices)):
		tmp = indices[i] - indices[i - 1] - 1 - 2 * k
		if tmp > 0:
			cnt += ceil(tmp / (k + 1))
	tmp = indices[0] - k
	if tmp > 0:
		cnt += ceil(tmp / (k + 1))
	tmp = n - indices[-1] - k - 1
	if tmp > 0:
		cnt += ceil(tmp / (k + 1))
	print(cnt)


import math
t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	s = input()
	li = list(s)
	for i in range(n):
		if li[i] == '1':
			low = max(0, i - k)
			high = min(n - 1, i + k)
			li[low:high + 1] = ['j'] * (high + 1 - low)
	c = 0
	one = 1
	for i in range(n):
		if i + 1 < n and li[i] == li[i + 1] == '0':
			one += 1
		elif li[i] == '0':
			c += math.ceil(one / (k + 1))
			one = 1
	print(c)
	t -= 1


for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	arr = []
	ans = 0
	arr += [0 - k - 1]
	for i in range(len(s)):
		if s[i] == '1':
			arr += [i]
	arr += [n + k]
	for i in range(len(arr) - 1):
		ans += (arr[i + 1] - arr[i] - k - 1) // (k + 1)
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = str(input())
	ans = 0
	las = -1 * k - 2
	for i in range(n):
		if x[i] == '0':
			if i - las > k:
				ans += 1
				las = i
		else:
			if i - las <= k:
				ans -= 1
			las = i
	print(ans)


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())
for _ in range(ii()):
	(n, k) = mi()
	s = list(si())
	l = []
	prev = -1
	for i in range(n):
		if s[i] == '1':
			l.append(i - prev - 1)
			prev = i
	l.append(n - prev - 1)
	if l[0] == n:
		print(1 + (l[0] - 1) // (k + 1))
		continue
	ans = 0
	for i in range(len(l)):
		if i == 0:
			ans += l[i] // (k + 1)
		elif i == len(l) - 1:
			ans += l[i] // (k + 1)
		else:
			l[i] -= k
			x = l[i] // (k + 1)
			if x >= 0:
				ans += x
	print(ans)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, input().split()))

def In():
	return map(int, input().split())

def I():
	return int(input())
P = 1000000007

def main():
	for t in range(I()):
		(n, k) = In()
		count = 0
		for i in ('0' * k + input() + '0' * k).split('1'):
			count += max((len(i) - k) // (k + 1), 0)
		print(count)
main()


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	z = 0
	noz = 0
	if not '1' in s:
		print(math.ceil(n / (k + 1)))
	else:
		while z < len(s):
			if s[z] == '1':
				z += k + 1
			else:
				nz = z
				while z < len(s):
					if s[z] == '0':
						z += 1
					else:
						break
				if z == len(s):
					noz += math.ceil((z - nz) / (k + 1))
				elif z - nz - k > 0:
					noz += math.ceil((z - nz - k) / (k + 1))
				z = z + k + 1
		print(noz)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = []
	for i in range(len(s)):
		l.append(int(s[i]))
	cnt0 = m
	cnt = 0
	for i in range(len(s)):
		if l[i] == 0:
			if i == len(s) - 1:
				cnt0 += m
			cnt0 += 1
			if cnt0 >= 2 * m + 1:
				cnt += 1
				cnt0 -= m + 1
		else:
			cnt0 = 0
	print(cnt)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input().rstrip()
	s = ('0' * k + s + '0' * k).split('1')
	ans = 0
	for i in s:
		ans += max((len(i) - k) // (k + 1), 0)
	print(ans)


cases = int(input())
for i in range(cases):
	(n, k) = list(map(int, input().split(' ')))
	s = input()
	last = -k - 1
	cand = n + 1
	ret = 0
	for i in range(n):
		if s[i] == '0':
			if i - cand > k:
				ret += 1
				cand = i
			elif i - last > k:
				cand = min(cand, i)
		else:
			last = i
			if i - cand > k:
				ret += 1
			cand = n + 1
	ret += int(cand > last + k and cand != n + 1)
	print(ret)


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


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	l = []
	for i in range(n):
		if s[i] == '1':
			l.append(i + 1)
	if len(l) == 0:
		c = 0
		for i in range(0, n, k + 1):
			c += 1
		print(c)
	else:
		ans = 0
		if l[0] - 1 >= k + 1:
			ans += (l[0] - 1) // (k + 1)
		for i in range(1, len(l)):
			for j in range(l[i - 1] + k + 1, l[i] - k, k + 1):
				ans += 1
		if n - l[-1] >= k + 1:
			ans += (n - l[-1]) // (k + 1)
		print(ans)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
import math

def cal(n, k):
	qw = n - (2 * k + 1)
	if qw >= 0:
		return 1 + qw // (k + 1)
	else:
		return 0
for _ in range(int(input())):
	(n, k) = get_ints()
	s = input()
	i = 0
	count = 0
	arr = []
	for i in range(n):
		if s[i] == '1':
			arr.append(i)
	if len(arr) == 0:
		if n >= k + 2:
			count += 2
			ui = cal(n - 2, k)
			if ui > 0:
				print(count + ui)
			else:
				print(count)
			continue
		else:
			print(1)
			continue
	if arr[0] >= k + 1:
		count += 1
		ui = cal(arr[0] - 1, k)
		if ui > 0:
			count += ui
	if len(s) - arr[-1] - 1 >= k + 1:
		count += 1
		ui = cal(len(s) - arr[-1] - 2, k)
		if ui > 0:
			count += ui
	for i in range(len(arr) - 1):
		po = arr[i + 1] - arr[i] - 1
		count += cal(po, k)
	print(count)


import math

def findtable(string, k):
	if '1' in string:
		List = string.split('1')
		counter = 0
		counter += math.floor(len(List[0]) / (k + 1))
		counter += math.floor(len(List[len(List) - 1]) / (k + 1))
		for i in range(1, len(List) - 1):
			counter += math.floor((len(List[i]) - k) / (k + 1))
	else:
		counter = 1 + math.floor((len(string) - 1) / (k + 1))
	print(counter)
a = int(input())
for _ in range(a):
	k = int(input().split()[1])
	string = input()
	findtable(string, k)


import sys
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, d) = inp()
	a = [int(i) for i in str(input())]
	f1 = f = True
	c = ans = 0
	for i in range(n):
		if f == True:
			if a[i] == 0:
				c += 1
			else:
				f = False
				c = 0
			if c == d + 1:
				ans += 1
				c = 0
		else:
			if a[i] == 0:
				c += 1
			else:
				c = 0
			if c == 2 * d + 1:
				ans += 1
				c = d
	if c > d and c <= 2 * d or (f == True and c > 0):
		ans += 1
	print(ans)


from sys import stdin, stdout
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C
for _ in range(it()):
	(n, k) = mp()
	l = list(input())
	v = []
	x = k
	ans = 0
	for i in range(n):
		if l[i] == '0':
			x += 1
		else:
			x = 0
		if x >= 2 * k + 1:
			ans += 1
			x = k
	if x >= k + 1:
		ans += 1
	print(ans)


I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n, k) = I()
	s = list(input())
	ans = 0
	an = 0
	f = 0
	cn = 0
	if '1' in s:
		st = s.index('1')
	else:
		st = 2 * (n + k)
	if s[0] == '0' and st > k:
		s[0] = '1'
		ans += 1
	for i in range(n):
		if s[i] == '0':
			cn += 1
		else:
			cn = 0
		if cn == 2 * k + 1:
			s[i - k] = '1'
			ans += 1
			cn = k
	if cn >= k + 1:
		ans += 1
	print(ans)


from bisect import bisect_left
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	for i in range(n):
		s[i] = int(s[i])
	ind = []
	c = 0
	for i in range(n):
		if s[i] == 1:
			c += 1
			ind.append(i)
	ind.append(n)
	i = 0
	while i < n:
		if s[i] == 1:
			i += k + 1
			continue
		j = bisect_left(ind, i)
		if ind[j] == n:
			try:
				s[i] = 1
				i += k + 1
			except:
				break
			continue
		if ind[j] - i > k:
			s[i] = 1
			i += k + 1
			continue
		i += 1
	print(s.count(1) - c)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(input())
	ones = [i for i in range(n) if a[i] == '1']
	if ones == []:
		res = (n - 1) // (k + 1) + 1
		print(res)
	else:
		res = 0
		x = ones[0] - k
		if x > 0:
			res += (x - 1) // (k + 1) + 1
		x = n - ones[-1] - 1 - k
		if x > 0:
			res += (x - 1) // (k + 1) + 1
		for i in range(1, len(ones)):
			x = ones[i] - ones[i - 1] - 1 - 2 * k
			if x > 0:
				res += (x - 1) // (k + 1) + 1
		print(res)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	d = k + 1
	c = 0
	ans = 0
	if '1' in a:
		s = a.index('1')
		ans = s // d
		for i in range(s, n):
			if a[i] == '0':
				c += 1
			else:
				ans += max(0, c - k) // d
				c = 0
		ans += c // d
	else:
		ans += (n - 1) // d + 1
	print(ans)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	x = input()
	i = 0
	ct = 0
	ans = 0
	f = -1
	s = -1
	while i < n:
		if x[i] == '1':
			if f == -1:
				f = i
				ct = max(0, f - k)
				ans = ans + ct // (k + 1) + int(ct % (k + 1) != 0)
			else:
				s = i
				ct = max(0, s - f - 1 - 2 * k)
				ans = ans + ct // (k + 1) + int(ct % (k + 1) != 0)
				f = i
				s = -1
		i += 1
	if f == -1:
		ct = n
		ans = ans + ct // (k + 1) + int(ct % (k + 1) != 0)
	elif s == -1:
		ct = max(0, n - 1 - f - k)
		ans = ans + ct // (k + 1) + int(ct % (k + 1) != 0)
	print(ans)


import sys
try:
	sys.stdin = open('inputs.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
finally:
	input = sys.stdin.readline
	print = sys.stdout.write
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	stiing = input().strip()
	count = 0
	i = 0
	one = [float('-inf')]
	while i < n:
		if stiing[i] == '1':
			one.append(i)
		elif i - one[-1] > k:
			j = i
			while j <= i + k and j < n:
				if stiing[j] == '1':
					one.append(j)
					i = j
					break
				j += 1
			else:
				count += 1
				one.append(i)
				i = j - 1
		i += 1
	print(str(count))
	print('\n')


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list((int(i) for i in input()))
	if sum(a) == 0:
		print(math.ceil(n / (k + 1)))
		continue
	indexes = []
	for i in range(n):
		if a[i] == 1:
			indexes.append(i)
	ans = 0
	if indexes[0] - k > 0:
		ans += math.ceil((indexes[0] - k) / (k + 1))
	if n - 1 - (indexes[-1] + k) > 0:
		ans += math.ceil((n - k - indexes[-1] - 1) / (k + 1))
	for i in range(len(indexes) - 1):
		left = indexes[i]
		right = indexes[i + 1]
		if right - left - 1 - 2 * k > 0:
			ans += math.ceil((right - left - 1 - 2 * k) / (k + 1))
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	p = input()
	s = list(p.split('1'))
	count = 0
	for i in range(len(s)):
		if s[i] == '':
			continue
		start = k
		if i == 0 and p[i] == '0':
			start = 0
		for j in range(start, len(s[i]), k + 1):
			if i == len(s) - 1 and p[n - 1] == '0':
				count += 1
			elif len(s[i]) - j > k:
				count += 1
	print(count)


for _ in range(int(input())):
	(n, k) = [int(__) for __ in input().split()]
	tables = [int(___) for ___ in input()]
	if 1 not in tables:
		if n == k:
			print(1)
		else:
			print(1 + (n - 1) // (k + 1))
	else:
		shit = 0
		ans = tables.index(1) // (k + 1)
		for i in tables[tables.index(1) + 1:]:
			if i == 0:
				shit += 1
			else:
				ans += (shit - k) // (k + 1)
				shit = 0
		ans += shit // (k + 1)
		print(ans)


t = int(input())
for test in range(0, t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	s = input()
	s = '1' + s + '1'
	a = []
	ind = []
	p = 0
	for i in range(1, len(s)):
		if s[i] == '1':
			ind.append([p, i])
			a.append(i - p - 1)
			p = i
	ans = 0
	for i in range(0, len(a)):
		l = a[i] - 2 * k
		if ind[i][0] == 0:
			l += k
		if ind[i][1] == len(s) - 1:
			l += k
		d = k + 1
		N = (l - 1) / d + 1
		N = int(N)
		if N > 0:
			ans += N
	print(ans)


for test in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(input())
	indexone = []
	for i in range(n):
		if arr[i] == '1':
			indexone.append(i)
	if indexone == []:
		ans = 0
		ind = 0
		while ind < n:
			ans += 1
			ind += k + 1
		print(ans)
	else:
		flagstart = 0
		flagend = 0
		if 0 not in indexone:
			indexone = [0] + indexone
			flagstart = 1
		if n - 1 not in indexone:
			indexone.append(n - 1)
			flagend = 1
		ans = 0
		for i in range(len(indexone) - 1):
			(ind1, ind2) = (indexone[i], indexone[i + 1])
			if flagstart == 1 and ind1 == 0:
				ind = 0
				while ind < ind2 and abs(ind - ind2) > k:
					ans += 1
					ind += k + 1
			elif flagend == 1 and ind2 == n - 1:
				ind = ind1 + k + 1
				while ind < n:
					ans += 1
					ind += k + 1
			else:
				ind = ind1 + k + 1
				while ind < n and abs(ind - ind2) > k:
					ans += 1
					ind += k + 1
		print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	i = 0
	k1 = k + 1
	e = 1
	for i in range(n):
		if s[i] == '1':
			if k1 != 0:
				e -= 1
			k1 = k + 1
		elif k1 == 0:
			e += 1
			k1 = k + 1
		k1 -= 1
	print(e)


def process(start, end, span):
	return max(0, (end - start - 2 * span - 2) // (span + 1) + 1)
global data
for i in range(int(input())):
	(n, k) = map(int, input().split())
	data = input()
	one_index = []
	start = 0
	end = 0
	result = 0
	for j in range(0, len(data)):
		if data[j] == '1':
			one_index.append(j)
	if len(one_index) == 0:
		print((n - 1) // (k + 1) + 1)
		continue
	if one_index[0] != 0:
		result += max(0, one_index[0] // (k + 1))
	if one_index[-1] != n - 1:
		result += max(0, (n - one_index[-1] - 1) // (k + 1))
	if len(one_index) == 1:
		print(result)
		continue
	for j in range(len(one_index) - 1):
		result += process(one_index[j], one_index[j + 1], k)
	print(result)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	e = a.count('1')
	if e == 0:
		r = (n + k) // (k + 1)
	else:
		u = a.find('1')
		v = a.rfind('1')
		r = u // (k + 1) + (n - 1 - v) // (k + 1)
		if e > 1 and v - u > 2 * k:
			b = a[u + 1:v]
			c = 0
			for i in range(len(b)):
				if b[i] == '0':
					c += 1
				else:
					r += max(c - k, 0) // (k + 1)
					c = 0
			r += max(c - k, 0) // (k + 1)
	print(r)


tests = int(input())
for t in range(tests):
	(n, k) = map(int, input().split())
	a = input()
	free = 0
	i = 0
	no_ones = True
	first = True
	last = False
	while i < n:
		while i < n and a[i] == '1':
			first = False
			no_ones = False
			i += 1
		zeroes = 0
		while i < n and a[i] == '0':
			i += 1
			zeroes += 1
		if i >= n:
			last = True
		if not first and (not last):
			zeroes -= k
		if zeroes > 0:
			free += zeroes // (k + 1)
	if no_ones:
		free = n // (k + 1) if n % (k + 1) == 0 else n // (k + 1) + 1
	print(free)


t = int(input())

def divide(x, y):
	if x >= y:
		return x // y
	else:
		return 0
for case in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	occupied = []
	for i in range(n):
		if int(s[i]) == 1:
			occupied.append(i)
	length = len(occupied)
	tables = 0
	for i in range(length):
		if i == 0:
			tables = tables + divide(occupied[i], k + 1)
		if i == length - 1:
			tables = tables + divide(n - 1 - occupied[i], k + 1)
			if i != 0:
				tables = tables + divide(occupied[i] - occupied[i - 1] - 1 - k, k + 1)
		else:
			tables = tables + divide(occupied[i] - occupied[i - 1] - 1 - k, k + 1)
	if length == 0:
		tables = divide(n - 1, k + 1) + 1
	print(tables)


t = int(input())
for i in range(t):
	temp = input()
	temp = temp.split(' ')
	tables = int(temp[0])
	distance = int(temp[1])
	states = input()
	counter = distance
	avalible_seats = 0
	for table in states:
		if table == '0':
			counter += 1
			if counter >= 2 * distance + 1:
				avalible_seats += 1
				counter = distance
		else:
			counter = 0
	if counter >= distance + 1:
		avalible_seats += 1
	print(avalible_seats)


t = int(input())
while t > 0:
	(n, k) = [int(ele) for ele in input().split()]
	s = input()
	first_1 = -1000000
	last_1 = 1000000
	count = 0
	dist = []
	for i in range(n):
		dist.append([-1, -1])
	for i in range(n):
		if s[i] == '0':
			dist[i][0] = first_1
		else:
			first_1 = i
	for i in range(n - 1, -1, -1):
		if s[i] == '0':
			dist[i][1] = last_1
		else:
			last_1 = i
	first_1 = -1000000
	for i in range(n):
		if dist[i][0] != -1 and dist[i][1] != -1:
			mini = max(first_1, dist[i][0])
			if abs(i - mini) > k and abs(i - dist[i][1]) > k:
				count += 1
				first_1 = i
	print(count)
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	d = k
	flag = True
	s = list(input())
	c = 0
	i = 0
	for el in s:
		if flag and el == '0' and (d < 2 * k):
			d += 1
		elif flag and el == '0' and (d == 2 * k):
			c += 1
			d += 1
		elif flag and el == '0' and (d == 2 * k + 1):
			d = k + 1
		elif el == '1':
			flag = False
			d = 0
		elif not flag and el == '0' and (d < k):
			d += 1
		elif not flag and el == '0' and (d == k):
			flag = True
			d += 1
		i += 1
	if flag and d < 2 * k + 1:
		c += 1
	print(c)


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, k) = map(int, input().split())
	S = input().strip()
	A = []
	X = 0
	for s in S:
		if s == '0':
			X += 1
		else:
			A.append(X)
			X = 0
	if X != 0:
		A.append(X)
	if len(A) == 1 and A[0] == n:
		print(1 + (n - 1) // (k + 1))
		continue
	ANS = 0
	if S[0] == '0' and S[-1] == '0':
		ANS += A[0] // (k + 1) + A[-1] // (k + 1)
		for i in range(1, len(A) - 1):
			ANS += (A[i] - k) // (k + 1)
	elif S[0] == '0':
		ANS += A[0] // (k + 1)
		for i in range(1, len(A)):
			ANS += max(0, A[i] - k) // (k + 1)
	elif S[-1] == '0':
		ANS += A[-1] // (k + 1)
		for i in range(len(A) - 1):
			ANS += max(0, A[i] - k) // (k + 1)
	else:
		for i in range(len(A)):
			ANS += max(0, A[i] - k) // (k + 1)
	print(ANS)


def solve():
	INF = 10000000
	(N, K) = map(int, input().split())
	pos = input()
	leftDist = [0] * N
	rightDist = [0] * N
	ans = 0
	i = N - 1
	while i >= 0:
		if i == N - 1:
			rightDist[i] = 0 if pos[i] == '1' else INF
		else:
			rightDist[i] = 0 if pos[i] == '1' else rightDist[i + 1] + 1
		i -= 1
	for i in range(N):
		if i == 0:
			leftDist[i] = 0 if pos[i] == '1' else INF
		else:
			leftDist[i] = 0 if pos[i] == '1' else leftDist[i - 1] + 1
		if leftDist[i] > K and rightDist[i] > K:
			ans += 1
			leftDist[i] = 0
			rightDist[i] = 0
	return ans

def main():
	for _ in range(int(input())):
		print(solve())
main()


import sys, math

def count(x, k):
	return int(math.ceil(x / (k + 1)))

def max_seat(n, k, s):
	ans = 0
	stack = []
	seat = 1
	while seat <= n:
		if s[seat - 1] == '0':
			stack.append(seat)
			seat += 1
		else:
			while len(stack) > 0 and seat - stack[-1] <= k:
				stack.pop()
			seat += k + 1
			ans += count(len(stack), k)
			stack = []
	if len(stack) > 0:
		ans += count(len(stack), k)
		stack = []
	return ans
t = int(input())
for i in range(t):
	(n, k) = list(map(int, sys.stdin.readline().strip().split()))
	s = sys.stdin.readline().strip()
	print(max_seat(n, k, s))


from sys import stdin, stdout
import sys
from math import *
for __ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	ar = [-1] * n
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			ar[i] = i
		elif i == n - 1:
			continue
		else:
			ar[i] = ar[i + 1]
	x = 0
	ans = 0
	while x < n:
		if x == n - 1 and s[x] == '0':
			ans += 1
			break
		elif s[x] == '1':
			x += k + 1
		elif ar[x] - x > k or ar[x] == -1:
			ans += 1
			x += k + 1
		else:
			x += 1
	print(ans)


def tables(n, k, s):
	k1 = k + 1
	res = 1
	for x in range(n):
		if s[x] == '1':
			if k1 != 0:
				res -= 1
			k1 = k + 1
		elif k1 == 0:
			res += 1
			k1 = k + 1
		k1 -= 1
	return res
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	print(tables(n, k, s))


for __ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = input()
	c = 0
	ans = 0
	yes = 0
	for i in range(n):
		if a[i] == '0':
			c += 1
		elif yes == 0:
			yes = 1
			ans += i // (k + 1)
			c = 0
		else:
			c = max(c - 2 * k, 0)
			if c % (k + 1) == 0:
				ans += c // (k + 1)
			else:
				ans += c // (k + 1) + 1
			c = 0
	if yes == 1:
		c = max(c - k, 0)
	if c % (k + 1) == 0:
		ans += c // (k + 1)
	else:
		ans += c // (k + 1) + 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	dist = 0
	ans = 1
	for c in s:
		if c == '1':
			if dist <= k and ans:
				ans -= 1
			dist = 0
		elif dist > k:
			ans += 1
			dist = 0
		dist += 1
	print(ans)


for x in range(int(input())):
	(n, k) = list(map(int, input().split()))
	m = list(map(int, input()))
	l = 0
	i = 0
	while i < n:
		h = i
		if m[i] != 1:
			r = 'Y'
			for j in range(min(i + 1, n - 1), min(i + k + 1, n)):
				if m[j] == 1:
					r = 'N'
					h = j
			if r == 'Y':
				l += 1
		i = h + k + 1
	print(l)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input()))
	l = [0] + l
	if l.count(1) == 0:
		print(math.ceil(n / (k + 1)))
	else:
		(a, b) = (0, n)
		ans = 0
		for i in range(1, n + 1, 1):
			if l[i] == 1:
				a = i
				break
		for i in range(n, 0, -1):
			if l[i] == 1:
				b = i
				break
		last = a
		for i in range(a - 1, 0, -1):
			if abs(last - i) == k + 1:
				ans += 1
				last = i
		last = b
		for i in range(b + 1, n + 1, 1):
			if abs(last - i) == k + 1:
				ans += 1
				last = i
		last = a
		for i in range(a + 1, b + 1, 1):
			if l[i] == 1:
				ans += (i - k - 1 - (last + 1) + 1) // (k + 1)
				last = i
		print(ans)


for test in range(int(input())):
	(n, gap) = map(int, input().split())
	arr = input()
	arr = arr + '0' * gap
	coun = gap
	ans = 0
	for i in range(len(arr)):
		if arr[i] == '0':
			coun += 1
		if arr[i] == '1':
			coun = 0
		if coun > 2 * gap:
			ans += 1
			coun = coun - gap - 1
	print(ans)


for i in range(int(input())):
	(n, k) = input().split(' ')
	(n, k) = (int(n), int(k))
	s = input()
	ones = []
	for i in range(n):
		if s[i] == '1':
			ones.append(i)
	if ones == []:
		print((n - 1) // (k + 1) + 1)
	else:
		ans = 0
		one = len(ones) - 1
		if s[0] == '0':
			ans += ones[0] // (k + 1)
		if s[n - 1] == '0':
			ans += (n - 1 - ones[one]) // (k + 1)
		for i in range(one):
			ans += (ones[i + 1] - ones[i] - k - 1) // (k + 1)
		print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ans = []
	pind = -1
	for i in range(n):
		if s[i] == '1':
			ans.append(i - pind - 1)
			pind = i
	ans.append(n - pind - 1)
	if len(ans) == 1:
		print((ans[0] + k) // (k + 1))
	else:
		summa = 0
		summa += max(ans[0], 0) // (k + 1)
		summa += max(ans[-1], 0) // (k + 1)
		for i in range(1, len(ans) - 1):
			summa += max(ans[i] - 2 * k + k, 0) // (k + 1)
		print(summa)


t = int(input())
for _ in range(t):
	(nn, kk) = map(int, input().split())
	a = [int(i) for i in input()]
	if nn != 1:
		cc = 0
		ii = 0
		while ii < nn:
			if a[ii] == 0:
				j = ii - kk
				if j < 0:
					j = 0
				jj = ii + kk + 1
				if jj > nn:
					jj = nn
				s = sum(a[j:jj])
				s1 = sum(a[ii + 1:jj])
				if s == 0:
					rr = 0
				else:
					rr = 1
				if rr == 0:
					a[ii] = 1
					cc = cc + 1
					ii = jj - 1
				elif s1 != 0:
					ii = jj - 1
				else:
					ii = ii + 1
			else:
				ii = ii + kk
		print(cc)
	elif a[0] == 0:
		print(1)
	else:
		print(0)


def gib(l, r, k):
	t = 0
	for i in range(l, r + 1, k + 1):
		if i > l and i < r and (i + (k + 1) <= r):
			t += 1
	return t

def f(r, k):
	t = 0
	for i in range(r, -1, -(k + 1)):
		if i >= 0 and i < r:
			t += 1
	return t

def b(l, r, k):
	t = 0
	for i in range(l, r + 1, k + 1):
		if i > l and i <= r:
			t += 1
	return t

def cc(l, k):
	t = 0
	for i in range(0, l, k + 1):
		t += 1
	return t

def fuin(n, k, string):
	arr = []
	total = 0
	for i in range(n):
		if string[i] == '1':
			arr.append(i)
	if len(arr) == 0:
		return cc(n, k)
	for i in range(len(arr) - 1):
		total += gib(arr[i], arr[i + 1], k)
	if arr[0] != 0 and abs(arr[0] - 0) >= k:
		arr = [0] + arr
		total += f(arr[1], k)
	if arr[-1] != n - 1 and abs(arr[-1] - (n - 1)) >= k:
		arr.append(n - 1)
		total += b(arr[-2], arr[-1], k)
	return total
tc = int(input())
for _ in range(tc):
	(n, k) = map(int, input().split())
	string = str(input())
	print(fuin(n, k, string))


def f(s, k):
	right = [float('inf') for _ in range(len(s))]
	last = float('inf')
	for i in range(len(s) - 1, -1, -1):
		right[i] = last
		if s[i] == '1':
			last = i
	left = -(k + 1)
	max_value = 0
	for i in range(len(s)):
		if s[i] == '0' and i - left > k and (right[i] - i > k):
			max_value += 1
			left = i
		if s[i] == '1':
			left = i
	print(max_value)
t = int(input())
for i in range(t):
	(n, k) = input().split(' ')
	k = int(k)
	s = input()
	f(s, k)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	cntr = []
	res = 0
	for (i, x) in enumerate(s):
		if x == '1':
			cntr.append(i)
	if len(cntr) == 0:
		import math
		print(math.ceil(n / (k + 1)))
	elif len(cntr) == 1:
		res = 0
		res = cntr[0] // (k + 1) + (n - cntr[0] - 1) // (k + 1)
		print(res)
	else:
		res = 0
		if cntr[0] > k:
			res += cntr[0] // (k + 1)
		if cntr[-1] < n - k:
			res += (n - cntr[-1] - 1) // (k + 1)
		for i in range(len(cntr) - 1):
			diff = cntr[i + 1] - cntr[i] - 1
			if diff - k > 0:
				res += (diff - k) // (k + 1)
		print(res)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(input())
	ans = 0
	if '1' not in l:
		l[0] = '1'
		ans = 1
	if '1' not in l[:k + 1]:
		l[0] = '1'
		ans = 1
	if '1' not in l[-k - 1:]:
		l[-1] = '1'
		ans += 1
	for i in range(k, len(l) - k - 1):
		if '1' not in l[i - k:i + k + 1]:
			l[i] = '1'
			ans += 1
	print(ans)


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)


from math import inf
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	kk = inf
	f = True
	ans = 0
	li = -inf
	i = 0
	for c in s:
		if c == '0':
			if kk >= k:
				kk = 0
				ans += 1
				li = i
			else:
				kk += 1
		if c == '1':
			if abs(li - i) <= k:
				ans -= 1
			kk = 0
		i += 1
	print(ans)


def count(lst, k):
	a = []
	for i in range(len(lst)):
		if lst[i] == '1':
			a.append(i)
	prev = 0
	ans = 0
	n = len(lst)
	if len(a) == 0:
		return (n - 1) // (k + 1) + 1
	else:
		ans = a[0] // (k + 1)
		prev = a[0]
		for i in range(1, len(a)):
			m = a[i] - k - 1 - (prev + k + 1) + 1
			if m > 0:
				ans += (m - 1) // (k + 1) + 1
			prev = a[i]
		m = n - 1 - (prev + k + 1) + 1
		if m > 0:
			ans += (m - 1) // (k + 1) + 1
		return ans

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		lst = str(input())
		print(count(lst, k))
main()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	arr = list(s)
	arr1 = arr.copy()
	nega = 0 - k
	ans = []
	ans.append(-1)
	ans1 = []
	if '1' in arr:
		count = 0
		for i in range(n):
			if arr[i] == '1':
				ans.append(i)
		ans.append(n)
		for i in range(1, len(ans)):
			ans1.append(ans[i] - ans[i - 1] - 1)
		ans1[0] -= k
		ans1[len(ans1) - 1] -= k
		for i in range(1, len(ans1) - 1):
			ans1[i] -= 2 * k
		for i in range(len(ans1)):
			for j in range(0, ans1[i], k + 1):
				count += 1
				arr1[i] = '1'
	else:
		count = 0
		for i in range(0, len(arr), k + 1):
			count += 1
			arr1[i] = '1'
			ans.append(i)
	print(count)


testcases = int(input())
for i in range(testcases):
	(N, k) = map(int, input().split())
	table = input()
	vacant = 0
	j = 0
	addition = 0
	while j < N:
		if table[j] == '1':
			j += k + 1
			if vacant > 0:
				addition += vacant // (k + 1)
				vacant = 0
		else:
			vacant += 1
			j += 1
	if vacant > 0:
		addition += vacant // (k + 1)
		if vacant % (k + 1) > 0:
			addition += 1
	print(addition)


import sys
import math
import itertools
from copy import copy
from collections import deque, Counter
from decimal import Decimal

def s():
	return input()

def i():
	return int(input())

def S():
	return input().split()

def I():
	return map(int, input().split())

def L():
	return list(input().split())

def l():
	return list(map(int, input().split()))

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 9)
mod = 10 ** 9 + 7
t = i()
for p in range(t):
	(n, k) = I()
	s1 = list(s())
	ans = 0
	if s1[0] == '0':
		Flag = 1
		start = -k
	else:
		start = 1
	for j in range(n):
		if s1[j] == '1':
			l = max(j - start - 2 * k, 0)
			ans += math.ceil(l / (k + 1))
			start = j + 1
	if s1[-1] == '0':
		l = max(n - start - k, 0)
		ans += math.ceil(l / (k + 1))
	if n == 1 and s1[0] == '0':
		ans = 1
	print(max(ans, 0))


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = input()
	ans = 0
	i = 0
	while i < n:
		j = i + 1
		while j < n and a[j] != '1':
			j += 1
		l = 0
		if a[i] == '1':
			l = k
		r = 0
		if j < n and a[j] == '1':
			r = k
		d = j - i
		if l == k:
			d -= 1
		d -= l + r
		if d > 0:
			ans += (d + k) // (k + 1)
		i = j
	print(ans)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	li = input()
	count = 0
	i = 0
	count = 0
	while i < len(li):
		lb = False
		rb = False
		len0 = 0
		while i < len(li) and li[i] == '0':
			if i == 0:
				lb = True
			if i == len(li) - 1:
				rb = True
			len0 = len0 + 1
			i = i + 1
		if lb == False:
			len0 = len0 - k
		if rb == False:
			len0 = len0 - k
		if len0 >= 1:
			count = count + math.ceil(len0 / (k + 1))
		i = i + 1
	print(count)


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	(n, k) = get_tuple()
	st = input()
	if st.count('1') == 0:
		ind = 0
		ans = 1
		while ind + k + 1 < n:
			ans += 1
			ind += k + 1
		return ans
	indexes = []
	for (i, val) in enumerate(st):
		if val == '1':
			indexes.append(i)
	ans = 0
	i = indexes[0]
	while i - k - 1 >= 0:
		ans += 1
		i -= k + 1
	i = indexes[-1]
	while i + (k + 1) < n:
		ans += 1
		i += k + 1
	for (i, val) in enumerate(indexes[1:], 1):
		j = indexes[i - 1]
		j += k + 1
		while j + k < val:
			j += k + 1
			ans += 1
	return ans

def main():
	print(solve())
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	(res, cnt, flag) = (0, 0, 0)
	for i in s:
		if i == '0':
			cnt += 1
		else:
			if flag:
				res += max(0, (cnt - k) // (k + 1))
			else:
				res += max(0, cnt // (k + 1))
			flag = 1
			cnt = 0
	if not flag:
		res = 1
		cnt -= 1
	res += max(0, cnt // (k + 1))
	print(res)


I = input
for _ in range(int(I())):
	(n, k) = map(int, I().split())
	a = list(I())
	a = list(map(int, a))
	zero = []
	one = []
	for i in range(n):
		if a[i] == 0:
			zero.append(i)
		else:
			one.append(i)
	t = one[0] if len(one) > 0 else 2 * n + 1
	temp = one[0] if len(one) > 0 else 2 * n + 1
	ans = 0
	on = len(one)
	indt = 0 if len(one) > 0 else 2 * n
	for i in zero:
		if t <= i and indt < on - 1:
			indt += 1
			if temp < t:
				temp = t
			t = one[indt]
		if abs(i - temp) > k and abs(i - t) > k:
			ans += 1
			temp = i
	if len(one) == 0 and ans == 0:
		print(1)
	else:
		print(ans)


import math

def get_gaps(binary_str, k):
	gaps = []
	prev = -1
	for (i, bit) in enumerate(binary_str):
		if bit == '1':
			diff = i - prev - 1
			if prev == -1:
				diff += k
			gaps.append(diff)
			prev = i
	if prev != len(binary_str) - 1:
		if prev == -1:
			gaps.append(len(binary_str) + 2 * k)
		else:
			gaps.append(len(binary_str) - prev - 1 + k)
	return gaps

def count_inversions(binary_str, k):
	gaps = get_gaps(binary_str, k)
	count = 0
	for gap in gaps:
		if gap >= 2 * k + 1:
			count += math.ceil((gap - 2 * k) / (k + 1))
	return count
results = []
for _ in range(int(input())):
	(n, k) = [int(e) for e in input().split(' ')]
	binary_str = input()
	results.append(str(count_inversions(binary_str, k)))
print('\n'.join(results))


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		s = input()
		l = 0
		r = l + 1
		ans = 0
		while r < n:
			if s[r] == '1':
				if s[l] == '0' and r < n:
					len = r - l
					len -= k
				elif s[l] == '1' and r < n:
					len = r - l - 1
					len -= 2 * k
				ans += (len + k) // (k + 1)
				l = r
			r += 1
		if s[l] == '0' and r >= n and (s[r - 1] == '0'):
			len = n
			ans += (len + k) // (k + 1)
		elif s[l] == '1' and r >= n and (s[r - 1] == '0'):
			len = r - l - 1
			len -= k
			ans += (len + k) // (k + 1)
		print(ans)
main()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	st = input()
	count = 0
	ans = 0
	end = 0
	start = st.find('1')
	if start >= 0:
		ans += (start - k) // (k + 1) + min(1, (start - k) % (k + 1))
		start += 1
	else:
		ans += n // (k + 1) + min(1, n % (k + 1))
		start = n
	while 0 <= start < n:
		end = st[start:].find('1')
		if end != -1:
			count = end
			count -= 2 * k
			if count > 0:
				ans += count // (k + 1) + min(1, count % (k + 1))
			start += end + 1
		else:
			break
	start += k
	ans += max(0, (n - start) // (k + 1) + min(1, (n - start) % (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()
	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)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	x = list(s)
	ans = 0
	count = 0
	if n == k:
		if x == ['0'] * n:
			ans = 1
	else:
		if ''.join(x[:k + 1]) == ''.join(['0'] * (k + 1)):
			ans += 1
			x[0] = '1'
		if ''.join(x[n - k - 1:]) == ''.join(['0'] * (k + 1)):
			ans += 1
			x[n - 1] = '1'
	for i in range(n):
		if x[i] == '1':
			count = 0
		if x[i] == '0':
			count += 1
			if count == 2 * k + 1:
				ans += 1
				count = k
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(input())
	f = 1
	c = 0
	i = 0
	while i < n:
		f = 1
		if l[i] == '0':
			for j in range(1, k + 1):
				if i + j < n:
					if l[i + j] == '1':
						f = 0
						break
			if f == 1:
				c = c + 1
				l[i] = '1'
				i = i + k + 1
			else:
				i = i + 1 + j + k
		else:
			i = i + k + 1
	print(c)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	result = 0
	index = 0
	while index < n:
		r = index
		while r < n and r - index <= k and (s[r] != '1'):
			r += 1
		if r - index > k or r >= n:
			result += 1
			index = r
		else:
			while True:
				oldVal = r
				r += 1
				while r < n and r - oldVal <= k and (s[r] != '1'):
					r += 1
				if r - oldVal > k or r >= n:
					break
			index = r
	print(result)


T = int(input())

def handle_btw(l, r):
	return max(0, (r - l) // (k + 1) - 1)

def start(s):
	return s // (k + 1)

def handle(last, n):
	return (n - 1 - last) // (k + 1)
for t in range(T):
	(n, k) = [int(i) for i in input().split()]
	s = input()
	one_index = []
	for i in range(n):
		if s[i] == '1':
			one_index.append(i)
	if one_index == []:
		print(1 + (n - 1) // (k + 1))
	else:
		ans = start(one_index[0]) + handle(one_index[-1], n)
		m = len(one_index)
		if m > 1:
			for i in range(m - 1):
				ans += handle_btw(one_index[i], one_index[i + 1])
		print(ans)


import sys
import math
import operator as op
from functools import reduce
from bisect import *
from collections import deque

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def read_float_line():
	return [float(v) for v in sys.stdin.readline().split()]

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom

def index(a, x):
	i = bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return -1

def find_lt(a, x):
	i = bisect_left(a, x)
	if i:
		return i - 1
	return -1

def find_le(a, x):
	i = bisect_right(a, x)
	if i:
		return i - 1
	return -1

def find_gt(a, x):
	i = bisect_right(a, x)
	if i != len(a):
		return i
	return -1

def find_ge(a, x):
	i = bisect_left(a, x)
	if i != len(a):
		return i
	return -1
mod = int(1000000000.0) + 7
mod2 = 998244353
t = read_int()
for i in range(t):
	(n, k) = read_int_line()
	s = read_line()
	s = s
	cnt = []
	k += 1
	for i in range(n):
		if s[i] == '1':
			cnt.append(i)
	ans = 0
	if len(cnt) == 0:
		for i in range(0, n, k):
			ans += 1
		print(ans)
		continue
	elif len(cnt) == 1:
		r = 1
		while cnt[0] - r * k >= 0:
			ans += 1
			r += 1
		r = 1
		while cnt[0] + r * k < n:
			ans += 1
			r += 1
		print(ans)
		continue
	r = 1
	while cnt[0] - r * k >= 0:
		ans += 1
		r += 1
	for i in range(len(cnt) - 1):
		for j in range(cnt[i] + k, cnt[i + 1] - k + 1, k):
			ans += 1
	r = 1
	while cnt[-1] + r * k < n:
		ans += 1
		r += 1
	print(ans)


def Mesto(a, k):
	ans = 0
	j = 0
	for i in range(len(a)):
		if a[i] == '1':
			if i - j - 1 - k > 0:
				ans += (i - j - 1 - k) // (k + 1)
			j = i
	print(ans)
	return
m = int(input())
for i in range(m):
	(n, k) = map(int, input().split())
	a = str(input())
	a = '1' + k * '0' + a + k * '0' + '1'
	Mesto(a, k)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	st = input()
	pos = []
	j = -10 ** 7
	for i in range(n):
		if st[i] == '1':
			if i - j <= k:
				pos.pop()
			j = i
		elif st[i] == '0' and i - j > k:
			pos.append(i)
			j = i
	print(len(pos))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	first = -1
	justlast = 0
	ct = 0
	zero = -1
	for i in range(n):
		if s[i] == '1' and first == -1:
			if zero == 0:
				justlast = 0
				if i - justlast > k:
					ct = 1
					n1 = i - justlast - 2 * k - 1
					if n1 > 0:
						x = n1 // (k + 1)
						if n1 % (k + 1) == 0:
							ct += x
						else:
							ct += x + 1
			zero += 2
			first += 1
			justlast = i
		elif s[i] == '1':
			if i - justlast > 2 * k:
				n1 = i - justlast - 2 * k - 1
				if n1 > 0:
					x = n1 // (k + 1)
					if n1 % (k + 1) == 0:
						ct += x
					else:
						ct += x + 1
			justlast = i
		elif s[i] == '0':
			if i == 0:
				zero = 0
				justlast = -1
				if n == 1:
					ct = 1
			elif i == n - 1:
				if justlast == -1:
					x = n // (k + 1)
					if n % (k + 1) == 0:
						ct = x
					else:
						ct = x + 1
				else:
					n = i - justlast - k
					if n <= 0:
						break
					x = n // (k + 1)
					if n % (k + 1) == 0:
						ct += x
					else:
						ct += x + 1
	print(ct)


t = int(input())
for _ in range(t):
	left = True
	right = True
	ans = 0
	(n, k) = map(int, input().split())
	s = input()
	if s[0] == '1':
		left = False
	if s[-1] == '1':
		right = False
	cnt = 0
	for i in range(n):
		if s[i] == '0':
			cnt += 1
		if s[i] == '1':
			if left:
				ans += max(-(-(cnt - k) // (k + 1)), 0)
				cnt = 0
				left = False
			else:
				ans += max(-(-(cnt - 2 * k) // (k + 1)), 0)
				cnt = 0
	if right and left:
		ans += -(-cnt // (k + 1))
	elif right:
		ans += max(-(-(cnt - k) // (k + 1)), 0)
	print(ans)


import sys
from bisect import bisect_left, bisect_right
INF = 1 << 60
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	x = []
	for i in range(n):
		if s[i] == '1':
			x.append(i)
	ans = 0
	for i in range(n):
		if s[i] == '1':
			continue
		index1 = bisect_left(x, i)
		gap_left = INF
		gap_right = INF
		if len(x) > 0:
			if index1 == 0:
				gap_right = x[index1] - i - 1
			elif index1 == len(x):
				gap_left = i - x[-1] - 1
			else:
				gap_left = i - x[index1 - 1] - 1
				gap_right = x[index1] - i - 1
		if gap_left >= k and gap_right >= k:
			ans += 1
			x.insert(index1, i)
	print(ans)


from math import ceil

def check_social_distance(num_cases):
	num_cases = int(num_cases)
	for i in range(num_cases):
		line = input()
		line = line.split()
		n = int(line[0])
		k = int(line[1])
		s = input()
		ans = find_seats(s, n, k)
		print(ans)

def find_seats(s, n, k):
	i = 0
	seats = 0
	while i < n:
		if s[i] == '0':
			j = i + 1 if i + 1 < n and s[i + 1] != '1' else i
			while j + 1 < n and s[j + 1] != '1':
				j += 1
			length = j - i + 1
			if i - 1 >= 0 and s[i - 1] == '1':
				length -= k
			if j + 1 < n and s[j + 1] == '1':
				length -= k
			if length > 0:
				possible_seats = ceil(length / (k + 1))
				seats += possible_seats
			i = j + 1
		else:
			i += 1
	return seats
num_cases = input()
check_social_distance(num_cases)


testcases = int(input())
for j in range(testcases):
	(n, k) = map(int, input().split())
	string1 = [k for k in input()]
	pos = []
	for s in range(n):
		if string1[s] == '1':
			pos.append(s)
	pos.reverse()
	cv = 0
	count = 0
	while cv < n:
		nex = cv + k + 1
		if len(pos) != 0:
			if pos[-1] >= nex:
				if string1[cv] == '0':
					string1[cv] = '1'
					count += 1
				cv += k + 1
			else:
				cv = pos.pop()
		else:
			if string1[cv] == '0':
				string1[cv] = '1'
				count += 1
			cv += k + 1
	print(count)


def solve(s, n, k, ans):
	dp = [0]
	for i in s:
		dp.append(dp[-1])
		if i == '0':
			dp[-1] += 1
	good = 0
	i = 1
	while i <= n:
		if i - k - 1 >= 0:
			left = dp[i] - dp[i - k - 1]
			left_req = k + 1
		else:
			left = dp[i]
			left_req = i
			left -= good
		if i + k <= n:
			right = dp[i + k] - dp[i - 1]
			right_req = k + 1
		else:
			right = dp[-1] - dp[i - 1]
			right_req = n - i + 1
		if left == left_req and right == right_req:
			good += 1
			i += k + 1
		else:
			i += 1
	ans.append(good)

def main():
	t = int(input())
	ans = []
	for i in range(t):
		(n, k) = map(int, input().split())
		s = input()
		solve(s, n, k, ans)
	for i in ans:
		print(i)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = '0' * k + input()
	max_tables = 0
	i = 0
	while i < n:
		segment_len = 0
		found = s.find('1', i)
		if found != -1:
			segment_len = max(0, found - i - k)
			i = found + 1
		else:
			segment_len = len(s) - i
			i = n
		max_tables += segment_len // (k + 1)
	print(max_tables)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = input()
	arr = [int(i) for i in s]
	prev = sum(arr)
	y = min(k, n)
	temp = 0
	for i in range(y):
		temp += arr[i]
	for i in range(n):
		if i + k < n:
			temp += arr[i + k]
		if temp == 0:
			arr[i] = 1
			temp += 1
		if i - k >= 0:
			temp -= arr[i - k]
	nex = sum(arr)
	print(nex - prev)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	res = 0
	i = 0
	while i < n:
		j = i + 1
		while j < n and s[j] != '1':
			j += 1
		left = k if s[i] == '1' else 0
		right = k if j < n and s[j] == '1' else 0
		leng = j - i
		if left == k:
			leng -= 1
		leng -= left + right
		if leng > 0:
			res += (leng + k) // (k + 1)
		i = j
	print(int(res))


test = int(input())
for t in range(0, test):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	count = 0
	s = s + '2'
	for ch in s:
		if ch == '0':
			count = count + 1
		elif ch == '1':
			count = count - k
			if count > 0:
				ans = ans + (count + k) // (k + 1)
			count = -k
		elif count > 0:
			ans = ans + (count + k) // (k + 1)
	print(ans)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if '1' not in s:
		print(math.ceil(n / (k + 1)))
	else:
		left = s.find('1')
		right = s.rindex('1')
		lst = list()
		if left - k > 0:
			lst.append(left - k)
		if n - 1 - right - k > 0:
			lst.append(n - 1 - right - k)
		count = 0
		for i in s[left + 1:right]:
			if i == '0':
				count += 1
			else:
				if count - 2 * k > 0:
					lst.append(count - 2 * k)
				count = 0
		if count - 2 * k > 0:
			lst.append(count - 2 * k)
		res = 0
		for item in lst:
			res += math.ceil(item / (k + 1))
		print(res)


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P
from bisect import bisect_left as BL, bisect_right as BR
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT, inf as INFINITY

def player1():
	print('')

def player2():
	print('')

def isPrime(n):
	for i in range(2, MC(SQRT(n)) + 1):
		if n % i == 0:
			return False
	return True

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		s = input()
		pref = [INFINITY] * n
		suff = [INFINITY] * n
		prev = -1
		for i in range(n):
			if s[i] == '1':
				prev = i
				continue
			if s[i] == '0' and prev >= 0:
				pref[i] = prev
				continue
		prev = -1
		for i in range(n - 1, -1, -1):
			if s[i] == '1':
				prev = i
				continue
			if s[i] == '0' and prev >= 0:
				suff[i] = prev
				continue
		ans = 0
		prev = -1
		for i in range(n):
			if s[i] == '0':
				if prev == -1:
					if abs(pref[i] - i) > k and abs(suff[i] - i) > k:
						ans += 1
						prev = i
				elif min(abs(prev - i), abs(pref[i] - i)) > k and abs(suff[i] - i) > k:
					ans += 1
					prev = i
		print(ans)
main()


t = int(input())
for asda in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	a = [0] * n
	no = n + k
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			no = i
		a[i] = no
	lo = -k - 1
	for i in range(n):
		if s[i] == '1':
			lo = i
		elif i - lo > k and a[i] - i > k:
			ans += 1
			lo = i
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	prev = -1
	ans = 0
	i = 0
	while i < n:
		if s[i] == '1':
			if prev == -1:
				ans += i // (k + 1)
			else:
				m = (i - prev - 1) // (k + 1)
				if m > 0:
					ans += m
					if (i - prev - 1) % (k + 1) != k:
						ans -= 1
			prev = i
		i += 1
	ans += (n - 1 - prev) // (k + 1)
	if prev == -1 and n % (k + 1) != 0:
		ans += 1
	print(ans)


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


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input()))
	ind = []
	for i in range(n):
		if a[i] == 1:
			ind.append(i)
	if not ind:
		print(1 + (n - 1) // (k + 1))
	else:
		ans = 1 + (ind[0] - 1 - k) // (k + 1) if a[0] == 0 and ind[0] - 1 - k >= 0 else 0
		ans += (n - ind[-1] - 1) // (k + 1)
		i = 1
		while i < len(ind):
			ans += (ind[i] - ind[i - 1] - 1 - k) // (k + 1)
			i += 1
		print(ans)


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline().rstrip()

def lsi():
	return list(si())
res = ['Yes', 'No']
test_case = ii()
while test_case:
	test_case -= 1
	(n, k) = mi()
	a = lsi()
	ans = 0
	if '1' not in a:
		ans += 1
		a[0] = '1'
	f = a.index('1')
	if f > k:
		a[0] = '1'
		ans += 1
	l = n - a[::-1].index('1') - 1
	if n - l - 1 > k:
		a[-1] = '1'
		ans += 1
	c = 0
	for i in range(n):
		if a[i] == '0':
			c += 1
			if c == k * 2 + 1:
				ans += 1
				c = k
		else:
			c = 0
	print(ans)


def vys(x, y):
	return (x + y - 1) // y
tests = int(input())
for _ in range(tests):
	(n, k) = map(int, input().split())
	s = input()
	pol = []
	for i in range(n):
		if s[i] == '1':
			pol.append(i)
	if len(pol) == 0:
		print((n + k) // (k + 1))
		continue
	count = max(0, vys(pol[0] - k, k + 1))
	count += max(0, vys(n - (pol[-1] + k + 1), k + 1))
	for i in range(1, len(pol)):
		count += max(0, vys(pol[i] - pol[i - 1] - 1 - 2 * k, k + 1))
	print(count)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	s += '0' * k
	ans = 0
	cnt = k
	for i in range(n + k):
		if s[i] == '0':
			cnt += 1
			if cnt == 2 * k + 1:
				ans += 1
				cnt = k
		else:
			cnt = 0
	print(ans)


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def solve():
	(n, k) = num_input()
	s = list(input())
	prev = -1
	ans = 0
	flag = False
	for i in range(n):
		if s[i] == '1':
			flag = True
			if prev == -1:
				temp = i - (k + 1)
				while temp >= 0:
					ans += 1
					temp -= k + 1
				prev = i
			else:
				temp = i - (k + 1)
				while temp - prev > k:
					ans += 1
					temp -= k + 1
				prev = i
	if flag:
		remain = n - prev - 1
		if remain >= k:
			temp = prev + k + 1
			while temp < n:
				ans += 1
				temp += k + 1
		print(ans)
	elif n <= k:
		print(1)
	else:
		print(math.ceil(n / (k + 1)))
t = int(input())
for _ in range(t):
	solve()


import math
import sys

def getOptimalNumOfChairsFromEmptyTable(tableCount, minDistance):
	return math.ceil(tableCount / (minDistance + 1))

def calculate(tables, minDistance):
	personInBack = False
	availableTableCount = 0
	validChairCount = 0
	for table in tables:
		if table == '1':
			if personInBack:
				validChairCount -= minDistance
			validChairCount -= minDistance
			if validChairCount > 0:
				availableTableCount += getOptimalNumOfChairsFromEmptyTable(validChairCount, minDistance)
			validChairCount = 0
			personInBack = True
		else:
			validChairCount += 1
	if personInBack:
		validChairCount -= minDistance
	if validChairCount > 0:
		availableTableCount += getOptimalNumOfChairsFromEmptyTable(validChairCount, minDistance)
	return availableTableCount

def getInput():
	firstInput = sys.stdin.readline().rstrip().split(' ')
	minDistance = int(firstInput[1])
	tables = sys.stdin.read(int(firstInput[0]))
	sys.stdin.readline()
	return (tables, minDistance)
inputs = []
numOfInput = sys.stdin.readline()
for inputIndex in range(0, int(numOfInput)):
	inputs.append(getInput())
for lineInput in inputs:
	result = calculate(*lineInput)
	print(result)


import sys

def ii():
	return sys.stdin.readline().strip()

def idata():
	return [int(x) for x in ii().split()]

def solve_of_problem():
	(n, k) = idata()
	s = '0' * n + ii() + '0' * n
	data = [0] * (3 * n)
	count = 0
	for i in range(2 * n):
		count += 1 if s[i + k] == '1' else 0
		count -= 1 if i >= k and s[i - k - 1] == '1' else 0
		data[i] = 1 if count else 0
	data = data[n:2 * n]
	count = 0
	flag = 0
	for i in range(n):
		if flag == 0 and data[i] == 0:
			flag = k
			count += 1
		else:
			flag = max(0, flag - 1)
	print(count)
	return
for t in range(int(ii())):
	solve_of_problem()


import math
t = int(input())
for ii in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	for i in range(n):
		if s[i] == '1':
			l = max(0, i - k)
			h = min(n - 1, i + k)
			s[l:h + 1] = ['#'] * (h + 1 - l)
	c = 0
	one = 1
	for i in range(n):
		if i + 1 < n and s[i] == s[i + 1] == '0':
			one += 1
		elif s[i] == '0':
			c += math.ceil(one / (k + 1))
			one = 1
	print(c)


from collections import deque
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	start = 0
	ones = deque()
	for i in range(n):
		if a[i] == '1':
			ones.append(i)
	if '1' in a:
		start = a.index('1')
	else:
		start = n + k
	ind = -10 ** 12
	count = 0
	for i in range(start - k):
		if a[i] == '1':
			ind = i
		if i - k > ind:
			count += 1
			ind = i
	ind = start
	if len(ones):
		ones.popleft()
		if len(ones):
			ind2 = ones.popleft()
		else:
			ind2 = 10 ** 12
	for i in range(start + 1, n):
		if a[i] == '1':
			ind = i
			if len(ones):
				ind2 = ones.popleft()
			else:
				ind2 = 10 ** 12
		if i - k > ind and i + k < ind2:
			count += 1
			ind = i
	print(count)


from math import *
for pnireewnrkomowomfmmwomf in range(int(input())):
	k = int(input().split()[1])
	ans = 0
	l = list(map(lambda x: len(x), input().split('1')))
	if len(l) != 1:
		ans += l[0] // (k + 1)
		ans += l[len(l) - 1] // (k + 1)
		for i in range(1, len(l) - 1):
			ans += (l[i] - k) // (k + 1)
	else:
		ans += ceil(l[0] / (k + 1))
	print(ans)


for _ in range(int(input())):
	(n, k) = (int(x) for x in input().split())
	chairs = list(input())
	changes = 0
	change_one = True
	for i in range(min(k + 1, n)):
		if chairs[i] == '1':
			change_one = False
			break
	if change_one:
		chairs[0] = '1'
		changes = 1
	else:
		chairs = chairs[i:]
	counter = 0
	for c in chairs:
		if c == '1':
			counter = 0
		else:
			counter += 1
		if counter == 2 * k + 1:
			changes += 1
			counter -= k + 1
	if counter > k:
		changes += 1
	print(changes)


import math
from sys import stdin, stdout
from sys import maxsize

def digit(s):
	s = str(s)
	a = ''
	for i in range(len(s)):
		a = a + s[i] + ' '
	return [int(x) for x in a.split()]

def solve(s, n, k):
	li = []
	for i in range(n):
		if s[i] == 1:
			li.append([max(0, i - k), i + k])
	if len(li) > 0:
		ans = math.ceil(li[0][0] / (k + 1))
		for j in range(len(li) - 1):
			ans += math.ceil(max(0, li[j + 1][0] - li[j][1] - 1) / (k + 1))
		ans += math.ceil(max(0, n - li[-1][1] - 1) / (k + 1))
	else:
		ans = math.ceil(n / (k + 1))
	print(ans)
	pass
test = 1
test = int(input())
for t in range(0, test):
	(n, k) = list(map(int, input().split()))
	s = input()
	s = digit(s)
	ans = solve(s, n, k)


t = int(input())
for k in range(t):
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	ones = []
	for i in range(n):
		if s[i] == '1':
			ones.append(i)
	if len(ones) == 0:
		i = 0
		while i < n:
			count += 1
			i += k + 1
	elif len(ones) == 1:
		ind = ones[0]
		z = ind - 0
		i = 0
		while i < z and ind - i > k:
			count += 1
			i += k + 1
		i = ind + k + 1
		while i < n:
			count += 1
			i += k + 1
	else:
		ind = ones[0]
		z = ind - 0
		i = 0
		while i < z and ind - i > k:
			count += 1
			i += k + 1
		for i in range(len(ones) - 1):
			val = ones[i + 1] - ones[i] - 1
			j = ones[i] + k + 1
			while ones[i + 1] - j > k and j < ones[i + 1]:
				count += 1
				j += k + 1
		i = ones[-1] + k + 1
		while i < n:
			count += 1
			i += k + 1
	print(count)


def solve():
	(n, k) = map(int, input().split())
	summ = 0
	s = input()
	p1 = False
	p0 = 0
	a = len(s)
	if len(set(s)) == 1 and s[0] == '0':
		if a < k:
			print(1)
			return
		print((a + k) // (k + 1))
		return
	for i in s:
		if i == '0':
			p0 += 1
		else:
			if p1 and p0 > 2 * k:
				summ += (p0 - 2 * k + k) // (k + 1)
			elif not p1 and p0 > k:
				summ += (p0 - k + k) // (k + 1)
				p1 = True
			else:
				p1 = True
			p0 = 0
	if p0 > k:
		summ += (p0 - k + k) // (k + 1)
	print(summ)
for _ in range(int(input())):
	solve()


test_cases = int(input())
while test_cases > 0:
	(arrLen, distance) = map(int, input().split())
	dataStr = input()
	data = [e for e in dataStr]
	toPut = 0
	i = 0
	while i < arrLen:
		temp = 0
		if data[i] == '0':
			flag = True
			for j in range(1, distance + 1):
				if i + j < arrLen:
					if data[i + j] == '1':
						temp = j
						flag = False
						break
				else:
					break
			for k in range(1, distance + 1):
				if i - k < 0:
					break
				if data[i - k] == '1':
					flag = False
					break
			if flag == True:
				data[i] = '1'
				i += distance + 1
				toPut += 1
			else:
				i += distance + 1 + temp
		else:
			i += distance + 1
	print(toPut)
	test_cases -= 1


from sys import stdin
import sys
from collections import deque
for _ in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	s = stdin.readline().strip()
	pref = [-1] * (n + 1)
	suff = [-1] * (n + 1)
	if s[0] == '1':
		pref[0] = 0
	if s[n - 1] == '1':
		suff[n - 1] = n - 1
	for i in range(1, n):
		if s[i] == '1':
			pref[i] = i
		else:
			pref[i] = pref[i - 1]
	for i in range(n - 2, -1, -1):
		if s[i] == '1':
			suff[i] = i
		else:
			suff[i] = suff[i + 1]
	ans = 0
	for i in range(n):
		val1 = val2 = 1000000
		if pref[i] != -1:
			val1 = i - pref[i]
		if suff[i] != -1:
			val2 = suff[i] - i
		if min(val2, val1) > k:
			ans += 1
			pref[i] = i
		if pref[i + 1] < pref[i]:
			pref[i + 1] = pref[i]
	print(ans)


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


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	d = []
	prev = -1
	for i in range(n):
		if s[i] == '1':
			d.append(i - prev - 1)
			prev = i
	d.append(n - prev - 1)
	if len(d) == 1:
		print((d[0] - 1) // (k + 1) + 1)
		continue
	ans = d[0] // (k + 1) + d[-1] // (k + 1)
	for i in range(1, len(d) - 1):
		if d[i] > k:
			ans += (d[i] - k) // (k + 1)
	print(ans)


I = lambda : map(int, input().split())
for _ in [0] * int(input()):
	(n, k) = I()
	a = input()
	if '1' in a:
		x = a.index('1')
		y = n - 1 - a[::-1].index('1')
		ss = x // (k + 1) + (n - 1 - y) // (k + 1)
		if x != y:
			st = 0
			j = k + 1
			for i in a[x + k + 1:y + 1]:
				if i == '1':
					ss = ss + (j - st - k - 1) // (k + 1)
					st = j
				j = j + 1
	else:
		ss = (n - 1) // (k + 1) + 1
	print(ss)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		nk = list(map(int, input().split()))
		(n, k) = (nk[0], nk[1])
		s = str(input())
		pos = []
		for j in range(len(s)):
			if s[j] == '1':
				pos.append(j)
		if len(pos) == 0:
			print(1 + (len(s) - 1) // (k + 1))
			continue
		mx = pos[0] // (k + 1)
		for j in range(1, len(pos)):
			x = pos[j] - pos[j - 1] - 1
			mx += (x - k) // (k + 1)
		if len(pos) >= 1:
			mx += (len(s) - pos[-1] - 1) // (k + 1)
		print(mx)
main()


from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')
tests = lambda : range(1, int_in() + 1)
case_out = lambda i, o: out('Case #{}: {}'.format(i, o))

def solve(n, k, s):
	gaps = []
	count = 0
	isFirst = True
	for item in s:
		if item == 1:
			if isFirst:
				gaps.append(count - k)
			else:
				gaps.append(count - 2 * k)
			count = 0
			isFirst = False
		else:
			count += 1
	if isFirst:
		gaps.append(count)
	else:
		gaps.append(count - k)
	result = 0
	for gap in gaps:
		if gap > 0:
			result += (gap + k) // (k + 1)
	return result
for i in tests():
	(n, k) = arr_in()
	s = [int(x) for x in str_in()]
	out(solve(n, k, s))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().strip().split()))
	s = list(map(int, list(input().strip())))
	cumsum = [0]
	for e in s:
		cumsum.append(cumsum[-1] + e)
	idx = 0
	ans = 0
	while idx < n:
		if s[idx] == 1:
			idx += k + 1
			continue
		idx1 = idx + 1
		if cumsum[min(idx1 + k, n)] - cumsum[idx1 - 1] == 0:
			ans += 1
			idx += k + 1
		else:
			i = idx
			while i <= min(idx + k, n - 1) and s[i] != 1:
				i += 1
			idx = i
	print(ans)


from sys import stdin
input = stdin.readline
from math import ceil
from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input().rstrip()
	ans = 0
	if '1' not in s:
		ans += ceil(n / (k + 1))
		print(ans)
		continue
	a = s.find('1')
	b = n - s[::-1].find('1') - 1
	for i in s[a:b].split('1'):
		if i:
			ans += ceil((len(i) - k * 2) / (k + 1))
	ans += ceil((a - k) / (k + 1)) if ceil((a - k) / (k + 1)) > 0 else 0
	ans += ceil((n - b - 1 - k) / (k + 1)) if ceil((n - b - 1 - k) / (k + 1)) > 0 else 0
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(a, ans, mark, zinb) = (list(str(input())), 0, [], [])
	if a == ['0'] * n:
		a[0] = '1'
		ans += 1
	for i in range(n):
		if a[i] == '1':
			mark.append(i + 1)
	for i in range(len(mark) - 1):
		zinb.append(mark[i + 1] - mark[i] - 1)
	for i in range(len(zinb)):
		if (zinb[i] - k) // (k + 1) > 0:
			ans += (zinb[i] - k) // (k + 1)
	if (mark[0] - 1) // (k + 1) > 0:
		ans += (mark[0] - 1) // (k + 1)
	if (n - mark[len(mark) - 1]) // (k + 1) > 0:
		ans += (n - mark[len(mark) - 1]) // (k + 1)
	print(ans)


for _t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(input())
	ans = 0
	f = set()
	for i in range(n):
		if a[i] == '1':
			for j in range(max(0, i - k), min(n + 1, i + k + 1)):
				f.add(j)
	for i in range(n):
		if i not in f:
			ans += 1
			for j in range(max(0, i - k), min(n + 1, i + k + 1)):
				f.add(j)
	print(ans)


t = int(input())
for i in range(t):
	nk = list(map(int, input().split()))
	tables = list(input())
	n = nk[0]
	k = nk[1]
	cntr = k
	start = tables[0]
	tcounter = 0
	iszeroflag = True
	for j in tables:
		if j == '1':
			cntr = 0
			iszeroflag = False
		else:
			cntr += 1
			if cntr == 2 * k + 1:
				tcounter += 1
				cntr = k
	if cntr >= k + 1:
		tcounter += 1
	print(tcounter)


t = int(input())
import math
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ranges = []
	c = 0
	l = -1
	for i in range(n):
		if s[i] == '0':
			c += 1
		else:
			l = i
			break
	if l == -1:
		ranges.append(c)
		print(math.ceil(c / (k + 1)))
	else:
		ranges.append(max(0, c - k))
		c = 0
		for j in range(l, n):
			if s[j] == '0':
				c += 1
			else:
				ranges.append(max(0, c - 2 * k))
				c = 0
		ranges.append(max(0, c - k))
		ans = 0
		for i in ranges:
			ans += math.ceil(i / (k + 1))
		print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for r in range(t):
	(n, k) = map(int, input().split())
	s = input().strip('\n')
	l = []
	for i in range(n):
		l.append(s[i])
	count = 0
	i = 0
	while i < n:
		if i >= n:
			break
		if l[i] == '1':
			i += k + 1
		else:
			flag = True
			for j in range(i + 1, i + k + 1):
				if j >= n:
					break
				if l[j] == '1':
					flag = False
					break
			if flag == True and i < n:
				l[i] = '1'
				count += 1
				i += k + 1
			else:
				while l[i] != '1' and i < n:
					i += 1
				i += k + 1
	print(count)


t = int(input())
while t > 0:
	t -= 1
	(n, k) = [int(x) for x in input().split()]
	l = input()
	store = []
	for i in range(n):
		if l[i] == '1':
			store.append(i)
	l1 = len(store)
	tot = 0
	if l1 >= 2:
		h = store[0]
		if h - 1 >= k:
			tot += 1
			h -= 1
			tot += (h + 1) // (k + 1) - 1
		for i in range(0, l1 - 1):
			h = store[i + 1] - store[i] - 1
			tot += (h + 1) // (k + 1) - 1
		h = n - store[l1 - 1] - 1
		if h - 1 >= k:
			tot += 1
			h -= 1
			tot += (h + 1) // (k + 1) - 1
	elif l1 == 0:
		h = n
		if h - 2 >= k:
			tot += 2
			h -= 2
			tot += (h + 1) // (k + 1) - 1
		else:
			tot = 1
	elif l1 == 1:
		h = store[0]
		if h - 1 >= k:
			tot += 1
			h -= 1
			tot += (h + 1) // (k + 1) - 1
		h = n - store[0] - 1
		if h - 1 >= k:
			tot += 1
			h -= 1
			tot += (h + 1) // (k + 1) - 1
	print(tot)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	table = input()
	person = 0
	count = 0
	first = 0
	for i in range(n):
		if table[i] == '1':
			if first == 0:
				person += count // (k + 1)
			else:
				person += (count - k) // (k + 1)
			count = 0
			first = 1
		else:
			count += 1
			if i == n - 1 and first == 0:
				person += 1 + (count - 1) // (k + 1)
			elif i == n - 1:
				person += count // (k + 1)
	print(person)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def solve(n, k, s):
	ones_i = [i for i in range(n) if s[i] == '1']
	m = len(ones_i)
	if m == 0:
		return n // (k + 1) + (1 if n % (k + 1) > 0 else 0)
	ans = 0
	for i in range(1, len(ones_i)):
		ans += max(0, ones_i[i] - ones_i[i - 1] - 1 - k) // (k + 1)
	if ones_i[0] != 0:
		left = max(0, ones_i[0] - k)
		ans += left // (k + 1) + (1 if left % (k + 1) > 0 else 0)
	if ones_i[-1] != n - 1:
		left = max(0, n - (ones_i[-1] + k) - 1)
		ans += left // (k + 1) + (1 if left % (k + 1) > 0 else 0)
	return ans

def main():
	for _ in range(ri()):
		(n, k) = ria()
		s = rs()
		wi(solve(n, k, s))
main()


t = int(input())
for i in range(t):
	[n, k] = list(map(int, input().split()))
	s = input()
	if s[0] == '0':
		s = '0' * k + s
	if s[-1] == '0':
		s = s + '0' * k
	s = s.split('1')
	res = 0
	for element in s:
		if len(element) > 2 * k:
			res += (len(element) + 1) // (k + 1) - 1
	print(res)


t = int(input())
res = []
for i in range(t):
	(n, k) = map(int, input().split())
	string = input()
	j = 0
	(l, r) = (True, True)
	count = 0
	while j < len(string):
		r = True
		if string[j] == '1':
			l = False
			j += 1
		elif string[j] == '0':
			dem = 0
			while string[j + dem] == '0':
				if j + dem + 1 < len(string):
					dem += 1
				else:
					dem += 1
					break
			else:
				r = False
			j += dem
			if l and r:
				count += 1 + (dem - 1) // (k + 1)
			elif not l and (not r):
				dem -= 2 * k
				if dem > 0:
					count += 1 + (dem - 1) // (k + 1)
			else:
				dem -= k
				if dem > 0:
					count += 1 + (dem - 1) // (k + 1)
	res.append(count)
print('\n'.join([str(i) for i in res]))


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input().strip()
	c = 0
	j = 0
	dis = []
	while j < n:
		if s[j] == '1':
			dis.append(c)
			c = 0
		else:
			c = c + 1
		j = j + 1
	ans = 0
	if dis == []:
		ans = math.ceil(c / (k + 1))
	else:
		if s[-1] != '1':
			dis.append(c)
		if s[0] == '0':
			if dis[0] - k >= 1:
				ans = ans + math.ceil((dis[0] - k) / (k + 1))
				del dis[0]
			else:
				del dis[0]
		if len(dis) >= 1:
			if s[-1] == '0':
				if dis[-1] - k >= 1:
					ans = ans + math.ceil((dis[-1] - k) / (k + 1))
					del dis[-1]
				else:
					del dis[-1]
		for v in dis:
			if v - 2 * k >= 1:
				ans = ans + math.ceil((v - 2 * k) / (k + 1))
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	num = k
	ans = 0
	k2 = k + 1
	for i in s:
		if i == '0':
			num += 1
		else:
			ans += (num - k) // k2
			num = 0
	ans += num // k2
	print(ans)


cases = int(input())
output_list = []
for case in range(cases):
	(len, dist) = list(map(int, input().split()))
	table = list(input())
	counter = 0
	table_loop = 0
	while table_loop < table.__len__():
		flag = 1
		for in_loop in range(-dist, dist + 1):
			if table_loop + in_loop in range(table.__len__()):
				if table[table_loop + in_loop] == '1':
					flag = 0
					table_loop += dist + in_loop + 1
					break
				else:
					pass
		if flag:
			table[table_loop] = '1'
			counter += 1
	output_list.append(counter)
for outt in output_list:
	print(outt)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	j = 0
	yf = True
	ans = 0
	fk = 0
	while j < n:
		if yf and s[j] == '0':
			ans += 1
			yf = False
			fk = k
		elif not yf:
			if s[j] == '1':
				ans -= 1
				fk = k
			else:
				fk -= 1
		elif yf and s[j] == '1':
			fk = k
			yf = False
		if fk == 0:
			yf = True
		j += 1
	print(ans)


def tables_per_segment(seg_len, spacing):
	return seg_len // (spacing + 1)

def process():
	[n, k] = list(map(int, input().strip().split()))
	string = input().strip()
	ones = [i for (i, elem) in enumerate(string) if elem == '1']
	res = 0
	next_one_index = 0
	(prev_one, next_one) = (None, ones[next_one_index] if len(ones) > next_one_index else None)
	for (i, elem) in enumerate(string):
		if elem == '1':
			prev_one = next_one
			next_one_index += 1
			next_one = ones[next_one_index] if len(ones) > next_one_index else None
			continue
		if not (prev_one is not None and i - prev_one <= k or (next_one is not None and next_one - i <= k)):
			res += 1
			prev_one = i
	print(res)
t = int(input())
for _ in range(t):
	process()


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
		else:
			ans += 1
			i += k + 1
	print(ans)


def func1(n, k):
	return (n - 1) // k

def func2(n, k):
	return (n - k) // k

def main():
	(n, k) = map(int, input().split())
	k += 1
	s = input()
	prev = -1
	ans = 0
	firstIndex = s.find('1')
	last1Index = s.rfind('1')
	if last1Index == -1:
		return 1 + (n - 1) // k
	for i in range(n):
		if s[i] == '1':
			if i == firstIndex:
				ans += func1(i - prev, k)
			else:
				ans += func2(i - prev, k)
			prev = i
	ans += func1(n - last1Index, k)
	return ans
t = int(input())
for _ in range(t):
	print(main())


from sys import stdin as lector
input = lector.readlines()
n = lambda l, k: int((l - k) / (1 + k))
for i in range(1, 2 * int(input[0]) + 1, 2):
	(L, k) = list(map(int, input[i].split(' ')))
	x = input[i + 1][0:-1]
	linea = list(map(int, list(x)))
	suma = sum(linea)
	if L < k + 1:
		if suma == 0:
			print(1)
		else:
			print(0)
	else:
		r = 0
		ks = []
		for o in range(0, k):
			ks.append('0')
		xx = ''.join(ks) + x + ''.join(ks)
		y = xx.split('1')
		for j in range(0, len(y)):
			if y[j] != '':
				r += n(len(y[j]), k)
		print(r)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = input()
	if len(s) <= k and '0' * len(s) == s:
		print(1)
	elif '0' * len(s) == s:
		print((len(s) + k) // (k + 1))
	else:
		in_between = False
		res = 0
		walker = 0
		for i in range(n):
			if s[i] == '1':
				if in_between:
					res += (walker - k) // (k + 1)
				else:
					res += walker // (k + 1)
					in_between = True
				walker = 0
			else:
				walker += 1
		res += walker // (k + 1)
		print(res)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = str(input())
	streak = 0
	ans = 0
	last_one = -1
	for i in range(n):
		if s[i] == '0':
			streak += 1
		else:
			if last_one == -1:
				streak -= k
			else:
				streak -= 2 * k
			if streak > 0:
				ans += streak // (k + 1)
				streak = streak % (k + 1)
			if streak > 0 and streak % (k + 1) != 0:
				ans += 1
			streak = 0
			last_one = i
	if last_one != -1:
		streak -= k
	if streak > 0:
		ans += streak // (k + 1)
		streak = streak % (k + 1)
	if streak > 0 and streak % (k + 1) != 0:
		ans += 1
	print(ans)


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	(n, k) = map(int, input().split())
	arr = list(input())
	ans = 0
	if arr.count('1') == 0:
		ans += 1
		arr[0] = '1'
	limit = 2 * k + 1
	zero = 0
	i = arr.index('1')
	while i < n:
		if arr[i] == '0':
			zero += 1
		else:
			zero = 0
		if zero == limit:
			ans += 1
			zero = k
			arr[i - k] = '1'
		i += 1
	i = arr.index('1') - 1
	zero = 0
	while i >= 0:
		if arr[i] == '0':
			zero += 1
		if zero == k + 1:
			ans += 1
			zero = 0
		i -= 1
	i = None
	for j in range(n):
		if arr[j] == '1':
			i = j
	i += 1
	zero = 0
	while i < n:
		if arr[i] == '0':
			zero += 1
		if zero == k + 1:
			ans += 1
			zero = 0
		i += 1
	print(ans)
t = int(input())
for _ in range(t):
	main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = 0
	a = list(input())
	i = 0
	while i < n:
		j = i + 1
		while j < n and a[j] != '1':
			j += 1
		leng = j - i
		if a[i] == '1':
			left = k
		else:
			left = 0
		if j < n and a[j] == '1':
			right = k
		else:
			right = 0
		if left == k:
			leng -= 1
		leng -= left + right
		while leng > 0:
			ans += 1
			leng = leng - (k + 1)
		i = j
	print(ans)


def main():
	t = int(input())
	for test in range(t):
		(n, k) = map(int, input().split())
		tables = list(map(int, list(input())))
		dist = k
		places = 0
		for (i, elem) in enumerate(tables):
			if not elem:
				dist += 1
			else:
				dist = -1
			if dist >= k and (not elem):
				flag = False
				for (j, elem_j) in enumerate(tables[min(i + 1, len(tables) - 1):min(i + k + 1, len(tables))]):
					if elem_j:
						flag = j + 2
						break
				if not flag:
					places += 1
					dist = -1
					tables[i] = 1
					elem = 1
				else:
					dist = 0
		print(places)
main()


import sys
inp = [x for x in sys.stdin.read().split()]
ii = 0
ttt = int(inp[ii])
ii += 1
for _ in range(ttt):
	(n, k) = (int(inp[ii]), int(inp[ii + 1]))
	ii += 2
	s = inp[ii]
	ii += 1
	pos = [-k - 1]
	for i in range(n):
		if s[i] == '1':
			pos.append(i)
	pos.append(n + k)
	res = 0
	for i in range(len(pos) - 1):
		if pos[i + 1] - pos[i] >= 2 * k + 2:
			res += (pos[i + 1] - pos[i]) // (k + 1) - 1
	print(res)


import sys
import math
t = int(input())
while t > 0:
	input = sys.stdin.readline()
	data = list(map(int, input.split()))
	n = data[0]
	k = data[1]
	s = sys.stdin.readline()
	arr = []
	for i in range(len(s)):
		if s[i] == '0' or s[i] == '1':
			arr.append(int(s[i]))
	ans = 0
	flag = 0
	for i in range(n):
		if arr[i] == 1:
			flag = 1
	if flag == 1:
		dist = []
		x = 0
		for i in range(n):
			if arr[i] == 0:
				x += 1
			else:
				dist.append(x)
				x = 0
		dist.append(x)
		for i in range(1, len(dist) - 1):
			if dist[i] >= 2 * k + 1:
				ans += math.floor((dist[i] + 1) / (k + 1))
				ans -= 1
		if dist[0] >= k + 1:
			ans += math.floor(dist[0] / (k + 1))
		if dist[-1] >= k + 1 and len(dist) > 1:
			ans += math.floor(dist[-1] / (k + 1))
	else:
		ans = n // (k + 1)
		x = n % (k + 1)
		if ans == 0:
			ans += 1
		elif x != 0:
			ans += 1
	print(ans)
	t -= 1


S = input
for _ in [0] * int(S()):
	k = int(S().split()[1])
	t = '0' * k
	print(sum((max(0, len(s) - k) // (k + 1) for s in (t + S() + t).split('1'))))


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


t = int(input())
for jack in range(t):
	(n, k) = map(int, input().split())
	s = input()
	temp = 0
	zeroes = []
	for i in range(n):
		if s[i] == '1':
			if temp:
				zeroes.append(temp)
			zeroes.append('1')
			temp = 0
		else:
			temp += 1
	if temp:
		zeroes.append(temp)
	if zeroes[0] == 0:
		zeroes.pop(0)
	r = 0
	x = len(zeroes)
	for i in range(len(zeroes)):
		if zeroes[i] != '1':
			if 0 <= i - 1 < x and 0 <= i + 1 < x:
				r += max(zeroes[i] - k, 0) // (k + 1)
			elif 0 <= i - 1 < x or 0 <= i + 1 < x:
				r += zeroes[i] // (k + 1)
			else:
				r += (zeroes[i] + k) // (k + 1)
	print(r)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	flg = k
	for e in s:
		if e == '0':
			flg += 1
		else:
			flg = 0
		if flg == 2 * k + 1:
			ans += 1
			flg = k
	if flg > k:
		ans += 1
	print(ans)


import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda : int(input())
ip = lambda : [int(w) for w in input().split()]
for _ in range(inp()):
	(n, k) = ip()
	s = input()
	if s.count('0') == n:
		print((n - 1) // (k + 1) + 1)
		continue
	ind = [i for i in range(n) if s[i] == '1']
	ans = 0
	for i in range(len(ind) - 1):
		(a, b) = (ind[i], ind[i + 1])
		ans += (b - a - 1 - k) // (k + 1)
	ans += ind[0] // (k + 1)
	ans += (n - ind[-1] - 1) // (k + 1)
	print(ans)


import math
t = int(input())
for i in range(t):
	values = list(map(int, input().split()))
	(n, k) = (values[0], values[1] + 1)
	s = input()
	count = 0
	ones = s.count('1')
	if ones > 1:
		first_index = s.find('1')
		before_first_index = int(math.floor(first_index / k))
		last_index = s.rfind('1')
		after_last_index = int(math.floor((n - 1 - last_index) / k))
		latest_index = first_index
		for i in range(first_index + 1, last_index + 1, 1):
			if s[i] == '1':
				count += int(math.floor((i - latest_index) / k)) - 1
				latest_index = i
		count += before_first_index + after_last_index
	elif ones == 1:
		index = s.find('1')
		before = int(math.floor(index / k))
		after = int(math.floor((n - 1 - index) / k))
		count = before + after
	elif ones == 0 and n > k - 1:
		i = 0
		while i < n:
			count += 1
			i += k
	elif ones == 0 and n <= k - 1:
		count = 1
	print(count)


import sys
t = int(sys.stdin.readline())
while t:
	(n, k) = map(int, sys.stdin.readline().split())
	s = sys.stdin.readline().strip()
	prefix = [0] * n
	suffix = [0] * n
	lastone = -1
	nextone = -1
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			nextone = i
		suffix[i] = nextone
	count = 0
	for i in range(n):
		if s[i] == '1':
			lastone = i
		if lastone == -1:
			if abs(i - suffix[i]) > k or suffix[i] == -1:
				count += 1
				lastone = i
		elif abs(i - lastone) > k:
			if suffix[i] == -1 or abs(i - suffix[i]) > k:
				count += 1
				lastone = i
	print(count)
	t -= 1


import os
import operator
import sys
from io import BytesIO, IOBase

def inar():
	return [int(el) for el in input().split()]

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		st = input()
		res = []
		for i in range(n):
			if st[i] == '1':
				res.append(i)
		count = 0
		if len(res) == 0:
			t = 0
			for i in range(0, n, k + 1):
				t += 1
			print(t)
			continue
		if len(res) == 1:
			t = 0
			ans = res[0] // (k + 1)
			t += ans
			ans = (n - 1 - res[0]) // (k + 1)
			t += ans
			print(t)
			continue
		for i in range(len(res)):
			if i == 0:
				if res[i] != 0:
					ans = res[i] // (k + 1)
					count += ans
				continue
			if i == len(res) - 1 and res[i] != n - 1:
				ans = (n - 1 - res[i]) // (k + 1)
				count += ans
				ans = (res[i] - res[i - 1] - 1) // (k + 1)
				if (res[i] - res[i - 1] - 1) % (k + 1) == k:
					count += ans
				elif ans - 1 >= 0:
					count += ans - 1
				continue
			if i == len(res) - 1:
				ans = (res[i] - res[i - 1] - 1) // (k + 1)
				if (res[i] - res[i - 1] - 1) % (k + 1) == k:
					count += ans
				elif ans - 1 >= 0:
					count += ans - 1
			else:
				ans = (res[i] - res[i - 1] - 1) // (k + 1)
				if (res[i] - res[i - 1] - 1) % (k + 1) == k:
					count += ans
				elif ans - 1 >= 0:
					count += ans - 1
		print(count)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = input()
	s = []
	for i in range(n):
		s.append(l[i])
	i = 0
	count = 0
	while i < n:
		if s[i] == '1':
			for j in range(1, k + 1):
				if i + j == n:
					break
				elif s[i + j] == '1':
					break
				else:
					s[i + j] = '-1'
			i += j
		else:
			i += 1
	i = n - 1
	while i > -1:
		if s[i] == '1':
			for j in range(1, k + 1):
				if i - j < 0:
					break
				elif s[i - j] == '1':
					break
				else:
					s[i - j] = '-1'
			i -= j
		else:
			i -= 1
	i = 0
	while i < n:
		if s[i] == '0':
			count += 1
			i += k + 1
		else:
			i += 1
	print(count)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(input())
	a.append('1')
	b = 0
	count = 0
	for j in range(n + 1):
		if a[j] == '0':
			count += 1
		else:
			if count == j or j == n:
				if count == j and j == n:
					b += 1
					count -= 1
					count //= k + 1
					b += count
				else:
					count //= k + 1
					b += count
			elif count > k * 2:
				count -= k
				count //= k + 1
				b += count
			count = 0
	print(b)


for _ in range(int(input())):
	res = 0
	(n, k) = map(int, input().split())
	s = input()
	s = '0' * k + s + '0' * k
	l = s.split('1')
	for z in l:
		res += max((len(z) - k) // (k + 1), 0)
	print(res)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(input())
	b = []
	s = 0
	t = 0
	p = 0
	for i in range(len(a)):
		if a[i] == '0' and p == 0:
			s += 1
			p += 1
		elif a[i] == '0':
			t += 1
			if t == m + 1:
				s += 1
				t = 0
		if a[i] == '1' and p == 0:
			p += 1
		elif a[i] == '1' and t < m and (p > 0):
			s -= 1
			t = 0
		elif a[i] == '1':
			t = 0
	print(max(s, 0))


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lst = list(input())
	for i in range(n):
		if lst[i] == '1':
			for j in range(i - 1, i - k - 1, -1):
				try:
					if j > -1:
						lst[j] = '2'
				except:
					break
			for j in range(i + 1, i + k + 1):
				try:
					lst[j] = '2'
				except:
					break
	c = 0
	grp = 0
	for i in range(n):
		if lst[i] != '0':
			c += math.ceil(grp / (1 + k))
			grp = 0
		else:
			grp += 1
	c += math.ceil(grp / (1 + k))
	grp = 0
	print(c)


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, k) = map(int, input().split())
	s = input()
	prev = -(k + 1)
	c = 0
	for (i, a) in enumerate(s):
		if a == '0' and i - prev == k + 1:
			c += 1
			prev = i
		if a == '1':
			if i - prev <= k:
				c -= 1
				prev = i
			else:
				prev = i
	print(c)


import sys
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(input())
	ones = []
	for i in range(n):
		if a[i] == '1':
			ones.append(i)
	ans = 0
	if len(ones) == 0:
		i = 0
		while i < n:
			ans += 1
			i += k + 1
		print(ans)
	else:
		ind = 0
		if a[ind] == '0':
			pv = -k - 1
			nx = ones[0]
		elif len(ones) == 1:
			pv = 0
			nx = n - 1 + k + 1
		else:
			pv = 0
			nx = ones[1]
		for i in range(n):
			if i >= nx:
				pv = nx
				ind += 1
				if ind < len(ones):
					nx = ones[ind]
				else:
					nx = n - 1 + k + 1
			if i - pv >= k + 1 and nx - i >= k + 1:
				ans += 1
				pv = i
		print(ans)


t = int(input())
p = 1
while p <= t:
	(n, k) = map(int, input().split())
	s = input()
	s = '1' + '0' * k + s + '0' * k + '1'
	i = 0
	cnt = ans = 0
	i = 0
	while i < len(s):
		if s[i] == '0':
			cnt += 1
		else:
			cnt = 0
		if cnt == 2 * k + 1:
			ans += 1
			cnt = k
		i += 1
	print(ans)
	p += 1


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	s = input()
	ans = 0
	i = 0
	while i <= n - 1:
		l = max(0, i - k)
		r = min(n - 1, i + k)
		if '1' not in s[l:r + 1]:
			ans += 1
			i = r + 1
		else:
			i = s[l:r + 1].rfind('1') + l + k + 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	(n, k) = map(int, input().split())
	s = 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 math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().strip().split(' '))
	s = input()
	s = list(s)
	p = [0]
	for j in range(n):
		if s[j] == '1':
			p.append(j + 1)
	p.append(n + 1)
	l = len(p)
	c = 0
	if len(p) == 2:
		c = math.floor((n + k) / (k + 1))
	else:
		for j in range(1, l):
			if j == 1 and p[j] != 1:
				p1 = math.floor((p[j] - p[j - 1] + k) / (k + 1)) - 1
				if p1 >= 0:
					c += p1
			elif j == l - 1 and p[j - 1] != n:
				c += math.floor((p[j] - p[j - 1] + k) / (k + 1)) - 1
			else:
				p1 = math.floor((p[j] - p[j - 1] + 1 + k) / (k + 1)) - 2
				if p1 >= 0:
					c += p1
	print(c)


t = int(input())
while t > 0:
	t = t - 1
	(n, k) = map(int, input().split())
	s = input()
	n = len(s)
	l = list(s)
	A = [0] * n
	B = []
	for i in range(n):
		if l[i] == '1':
			B.append(i)
			A[i] = 1
	if B == []:
		c = 0
		for i in range(0, n, k + 1):
			c = c + 1
		print(c)
	else:
		i = 0
		j = 0
		while i < n and j < len(B):
			if abs(i - B[j]) <= k:
				A[i] = 1
				i = i + 1
			elif i > B[j]:
				j = j + 1
			else:
				i = i + 1
		c = 0
		i = 0
		while i < n:
			if A[i] == 0:
				c = c + 1
				prev = i
				j = i + 1
				while j < n:
					if A[j] == 0:
						if j - prev > k:
							c = c + 1
							prev = j
						j = j + 1
					else:
						j = j + 1
				break
			else:
				i = i + 1
		print(c)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	if n <= k:
		if '1' not in s:
			print(1)
		else:
			print(0)
		continue
	add = 1
	start = 0
	for i in range(k + 1):
		if s[i] == '1':
			add = 0
			start = i
			break
	i = start + k + 1
	while i < n:
		j = i
		one_i = True
		while j < n and j < i + k + 1:
			if s[j] == '1':
				one_i = False
				break
			j += 1
		if one_i:
			add += 1
			i = j
		else:
			i = j + k + 1
	print(add)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [len(x) for x in input().split('1')]
	cnt = 0
	if len(a) == 1:
		cnt = n // (k + 1) + (n % (k + 1) > 0)
	else:
		cnt += a[0] // (k + 1)
		cnt += a[-1] // (k + 1)
		for x in a[1:-1]:
			cnt += x // (k + 1)
			cnt -= x % (k + 1) != k
	print(cnt)


t = int(input())
while t:
	t -= 1
	(n, k) = list(map(int, input().strip(' ').split(' ')))
	string = input()
	allowed = 0
	next_one = 0
	count = 0
	for i in string:
		if i == '1':
			next_one = count
			break
		elif count == n - 1:
			next_one = float('inf')
		count += 1
	i = 0
	flag_one = False
	while i < n:
		if string[i] == '0':
			if next_one - i > k:
				allowed += 1
				i += k
		elif string[i] == '1':
			flag_one = True
			j = next_one + 1
			i += k
			while j < n:
				if string[j] == '1':
					next_one = j
					break
				elif j == n - 1:
					next_one = float('inf')
				j += 1
		i += 1
	if flag_one:
		print(allowed)
	elif allowed == 0:
		print(1)
	else:
		print(allowed)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = str(input())
	ans = 0
	ones = [0] * n
	for i in range(n):
		if s[i] == '1':
			if i == 0:
				ones[i] = 1
			else:
				ones[i] = ones[i - 1] + 1
		else:
			ones[i] = ones[i - 1]
	i = 0
	while i < n:
		if s[i] == '0':
			if i - k - 1 >= 0 and i + k < n:
				t1 = ones[i - 1] - ones[i - k - 1]
				t2 = ones[i + k] - ones[i]
				if t1 == 0 and t2 == 0:
					ans += 1
					i += k + 1
				else:
					i += 1
			elif i + k < n:
				if ones[i] == 0 and ones[i + k] - ones[i] == 0:
					ans += 1
					i += k + 1
				else:
					i += 1
			elif i - k - 1 >= 0:
				t1 = ones[-1] - ones[i]
				t2 = ones[i - 1] - ones[i - k - 1]
				if t1 == 0 and t2 == 0:
					ans += 1
					i += k + 1
				else:
					i += 1
			elif ones[-1] == 0 and ones[0] == 0:
				ans += 1
				i += k + 1
			else:
				i += 1
		else:
			i += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	string = input()
	arr = string.split('1')
	count = 0
	if len(arr) > 1:
		if string[0] == '0':
			l = len(arr[0])
			count += l // (k + 1)
		for i in arr[1:-1]:
			l = len(i)
			count += (l - k) // (k + 1)
		if string[-1] == '0':
			l = len(arr[-1])
			count += l // (k + 1)
	else:
		count = 1
		l = len(arr[0])
		count += (l - 1) // (k + 1)
	print(count)


def solve():
	(n, k) = map(int, input().split())
	a = input()
	x = k
	final = 0
	start = 0
	end = 0
	for i in range(0, n):
		if a[i] == '0':
			x += 1
		else:
			final += int((x - k) / (k + 1))
			x = 0
	final += int(x / (k + 1))
	print(final)
t = int(input())
for tt in range(0, t):
	solve()


t = int(input())
for T in range(t):
	x = input()
	(n, k) = x.split(' ')
	n = int(n)
	k = int(k)
	s = input()
	a = []
	for i in range(len(s)):
		a.append(int(s[i]))
	ind = []
	ind.append(0 - k)
	for i in range(len(a)):
		if a[i] == 1:
			ind.append(i + 1)
	ind.append(len(a) + 1 + k)
	diff = []
	for i in range(len(ind) - 1):
		diff.append(ind[i + 1] - ind[i] - 1 - 2 * k)
	s = 0
	for i in range(len(diff)):
		s = s + ((diff[i] - 1) // (k + 1) + 1)
	print(s)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	a = 0
	run = True
	try:
		for i in range(n + 1):
			if s[i] == '1':
				ind = i
				a += math.ceil((count + 1) / (k + 1)) - 1
				count = 0
				break
			else:
				count += 1
	except IndexError:
		a += math.ceil(count / (k + 1))
		run = False
	try:
		while run:
			if s[ind + 1] == '0':
				count += 1
			else:
				a += math.ceil((count + 2) / (k + 1)) - 2
				count = 0
			ind += 1
	except IndexError:
		a += math.ceil((count + 1) / (k + 1)) - 1
	print(a)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	st = input()
	pre = [0] * n
	pre[0] = int(st[0])
	ans = 0
	for i in range(1, n):
		pre[i] = int(st[i]) + pre[i - 1]
	j = 0
	while j < n:
		if int(st[j]) == 0:
			x = pre[n - 1] if j + k >= n else pre[j + k]
			y = pre[0] if j - k - 1 < 0 else pre[j - k - 1]
			if abs(x - y) == 0:
				ans += 1
				j = j + k + 1
			else:
				j = j + 1
		elif int(st[j]) == 1:
			j = j + k + 1
	print(ans)


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	l = input()
	ind = []
	for i in range(n):
		if l[i] == '1':
			ind.append(i)
	ans = 0
	if len(ind) == 0:
		ans = 1
		ans += (n - 1) // (k + 1)
	else:
		ans += (ind[0] - 0) // (k + 1)
		ans += (n - 1 - ind[-1]) // (k + 1)
		for i in range(len(ind) - 1):
			ze = ind[i + 1] - ind[i] - 1 - k
			if ze > 0:
				ans += ze // (k + 1)
	print(ans)


from sys import stdin
from math import ceil
from bisect import bisect_left

def iinput():
	return int(stdin.readline())

def sinput():
	return input()

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))

def bs(a, x):
	i = bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1
t = iinput()
while t:
	t -= 1
	(n, k) = minput()
	s = sinput()
	if s.count('0') == len(s):
		ans = ceil(n / (k + 1))
	elif s.count('1') >= len(s) - 1:
		ans = 0
	else:
		ans = 0
		z = 0
		i = 0
		flag = True
		while i < len(s):
			if s[i] == '0':
				z += 1
			else:
				if flag:
					z -= k
				else:
					z -= 2 * k
				flag = False
				if z > 0:
					if z == 1:
						ans += 1
					else:
						ans += ceil(z / (k + 1))
				z = 0
			i += 1
		z -= k
		if z > 0:
			if z == 1:
				ans += 1
			else:
				ans += ceil(z / (k + 1))
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = input()
	(c0, c1, s, i) = (0, 0, 0, 0)
	for j in range(n):
		if l[j] == '1':
			c1 += 1
	if c1 == 0:
		print((n + k) // (k + 1))
		continue
	while i < n:
		if l[i] == '1':
			c1 -= 1
			break
		c0 += 1
		i += 1
	s += c0 // (k + 1)
	c0 = 0
	i += 1
	while c1 != 0:
		if l[i] == '0':
			c0 += 1
		else:
			s += (c0 + 1) // (k + 1) - 1
			c0 = 0
			c1 -= 1
		i += 1
	s += (n - i) // (k + 1)
	print(s)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = '0' * k + input() + '0' * k
	one = a.count('1')
	d = 0
	x = 0
	go = False
	for j in a:
		if j == '0':
			x += 1
		else:
			x = 0
			go = False
		if x == k + 1:
			y = d
			x = 0
			go = True
		if go:
			if x == k:
				a = a[:y] + '1' + a[y + 1:]
				go = False
		d += 1
	print(a.count('1') - one)


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	s = input()
	i = 0
	cnt = 0
	while i < n and s[i] != '1':
		cnt += 1
		i += 1
	if i == n:
		ans = (cnt + k) // (k + 1)
	else:
		ans = cnt // (k + 1)
	cnt = 0
	for j in range(i, n):
		if s[j] == '0':
			cnt += 1
		else:
			p = (cnt - k) // (k + 1)
			if p > 0:
				ans += p
			cnt = 0
	ans += cnt // (k + 1)
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	A = list(str(input()))
	ans = 0
	dist = []
	for j in range(n):
		if A[j] == '1':
			dist.append(j)
	if len(dist) == 0:
		ans += -(-n // (k + 1))
	if len(dist) >= 1:
		ans += dist[0] // (k + 1)
		ans += (n - 1 - dist[-1]) // (k + 1)
	if len(dist) >= 2:
		for y in range(1, len(dist)):
			if dist[y] - dist[y - 1] - 1 >= k * 2 + 1:
				ans += 1
			ans += max((dist[y] - dist[y - 1] - 1 - (k * 2 + 1)) // (k + 1), 0)
	print(ans)


import itertools
from sys import stdin, stdout

def II():
	return int(stdin.readline())

def SI():
	return stdin.readline()[:-1]

def MI():
	return map(int, stdin.readline().split())
t = II()
for _ in range(t):
	(n, k) = MI()
	s = SI()
	a = [int(c) for c in s]
	ps = list(itertools.accumulate(a))
	ans = 0
	i = 0
	sd = k + 1
	while True:
		if i + sd > n - 1:
			if ps[i] == ps[-1] and a[i] == 0:
				ans += 1
			break
		if a[i] == 0 and ps[i] == ps[i + k]:
			ans += 1
			i += sd
		elif a[i] == 1:
			i += sd
		else:
			i += 1
	stdout.write(str(ans) + '\n')


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	a = []
	for i in range(n):
		if s[i] == '1':
			a.append(i)
	if len(a) == 0:
		ans = math.ceil(n / (k + 1))
	else:
		u = max(0, a[0] - 0)
		v = max(0, n - 1 - a[-1])
		cur = []
		ans = math.ceil((u - k) / (k + 1)) + math.ceil((v - k) / (k + 1))
		if len(a) >= 2:
			for i in range(1, len(a)):
				cur.append(a[i] - a[i - 1] - 1)
		for i in cur:
			ans += max(0, math.ceil((i - 2 * k) / (k + 1)))
	print(ans)


for _ in range(int(input())):
	(n, c) = map(int, input().split())
	s = input()
	ind = [0]
	x = 1
	for i in range(0, n):
		if s[i] == '1':
			ind.append(x)
		x = x + 1
	ind.append(n + 1)
	res = 0
	k = 0
	a = ind
	if len(ind) == 2:
		print(max((n + c) // (c + 1), 1))
		continue
	for i in range(1, len(ind)):
		if i == 1 or i == len(ind) - 1:
			x = a[i] - a[i - 1] - 1
		else:
			x = a[i] - a[i - 1] - c - 1
		if x < 0:
			continue
		res = x // (c + 1)
		if res > 0:
			k = k + res
	print(k)


def solve(n, k, e):
	big = float('inf')
	small = float('-inf')
	l = [0] * (n + 1)
	r = [0] * (n + 1)
	for i in range(n):
		if i == 0:
			if e[i] == 1:
				l[0] = 0
			else:
				l[0] = big
		elif e[i] == 1:
			l[i] = 0
		else:
			l[i] = l[i - 1] + 1
	count = 0
	for i in range(n - 1, -1, -1):
		if i == n - 1:
			if e[i] == 1:
				r[i] = 0
			else:
				r[i] = big
		elif e[i] == 1:
			r[i] = 0
		else:
			r[i] = r[i + 1] + 1
		if r[i] > k and l[i] > k:
			count += 1
			r[i] = 0
	return count

def main():
	t = int(input())
	for i in range(t):
		d = input()
		d = [int(i) for i in d.split()]
		a = d[0]
		b = d[1]
		e = input()
		e = [int(i) for i in e]
		ans = solve(a, b, e)
		print(ans)
main()


import math

def solve():
	(n, k) = map(int, input().split())
	s = input()
	if s.count('1') == 0:
		print(math.ceil(n / (k + 1)))
	else:
		(cnt, ans) = (0, 0)
		flag = True
		for x in s:
			if x == '0':
				cnt += 1
			else:
				if flag:
					ans += cnt // (k + 1)
					flag = False
				else:
					ans += max(0, (cnt + 1) // (k + 1) - 1)
				cnt = 0
		ans += cnt // (k + 1)
		print(ans)
t = int(input())
for _ in range(t):
	solve()


I = lambda : list(map(int, input().split(' ')))
J = lambda : int(input())
for _ in range(J()):
	(n, k) = I()
	lst = list(map(int, list(input())))
	l = []
	for i in range(len(lst)):
		if lst[i] == 1:
			l.append(i)
	if len(l) == 0:
		cnt = 0
		i = 0
		p = len(lst)
		while i * (k + 1) < p:
			cnt += 1
			i += 1
		print(cnt)
	elif k == 0:
		print(len(lst) - sum(lst))
	else:
		tables = 0
		term = 0
		for i in range(len(l) - 1):
			diff = l[i + 1] - l[i] - 1
			if diff > 2 * k:
				tables += (diff + 1) // (k + 1) - 1
		before = l[0] // (k + 1)
		after = (len(lst) - l[-1] - 1) // (k + 1)
		print(before + tables + after)


from math import *
from math import factorial as fact, comb as ncr
from bisect import bisect_left as bl
from bisect import bisect_right as br
from collections import Counter as ctr
from collections import deque as dq
from array import array
from re import search
li = lambda : list(map(int, input().split()))
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')
yn = lambda f: print('NYOE S'[f::2])
sbstr = lambda a, s: search('.*'.join(a), s)

def solve():
	for _ in range(int(input())):
		(n, k) = li()
		s = input()
		c = 0
		l = -(k + 1)
		for i in range(n):
			if s[i] == '1':
				l = i
			elif i - l == 2 * k + 1:
				l = l + k + 1
				c += 1
		if n - 1 - l >= k + 1:
			c += 1
		print(c)
solve()


from sys import stdin, stdout
from collections import defaultdict as dd
from collections import Counter as ctr
import statistics
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	b = []
	for i in range(n):
		if a[i] == '1':
			b.append(i)
	c = 0
	b.insert(0, -(k + 1))
	b.append(n + k)
	for i in range(1, len(b)):
		c += (b[i] - b[i - 1]) // (k + 1) - 1
	print(c)


import math
t = int(input())
for _ in range(t):
	(n, k) = [int(c) for c in input().split()]
	arr = [int(c) for c in input()]
	ans = 0
	zeros = []
	zc = 0
	for i in arr:
		if i == 1:
			zeros.append(zc)
			zc = 0
		else:
			zc += 1
	if arr[-1] == 0:
		zeros.append(zc)
	else:
		zeros.append(0)
	if len(zeros) == 1:
		ans = max(1, math.ceil(zeros[i] / (k + 1)))
	else:
		for i in range(len(zeros)):
			if i == 0 or i == len(zeros) - 1:
				if zeros[i] > k:
					ans += max(1, math.ceil((zeros[i] - k) / (k + 1)))
			elif zeros[i] > 2 * k:
				ans += max(1, math.ceil((zeros[i] - 2 * k) / (k + 1)))
	print(ans)


for _ in range(int(input())):
	(a, k) = map(int, input().split())
	l = list(input())
	f = -1
	c = 0
	x = 0
	i = 1
	if l[0] == '0':
		c += 1
	while i < a:
		if l[i] == '1':
			if i - x <= k:
				c -= 1
			x = i
		elif i - x > k:
			c += 1
			x = i
		i += 1
	print(c)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	l = list(s)
	count = 0
	i = 0
	while i < n:
		if l[i] == '0':
			f = True
			for j in range(i + 1, i + k + 1):
				if j < len(l):
					if l[j] == '1':
						i = j + 1 + k
						f = False
						break
				else:
					break
			if f:
				count += 1
				i += k + 1
		else:
			i += k + 1
	print(count)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from math import sqrt, floor, factorial, gcd, log
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def solve():
	for _ in range(int(input())):
		(n, k) = read()
		s = input()
		if s.count('1') == 0:
			print(n // (k + 1) + (n % (k + 1) != 0))
			continue
		arr = [len(i) for i in s.split('1')]
		ans = 0
		for i in range(len(arr)):
			if i != 0 and i != len(arr) - 1:
				if arr[i] >= k * 2 + 1:
					ans += (arr[i] - 2 * k) // (k + 1) + ((arr[i] - 2 * k) % (k + 1) >= 1)
			else:
				ans += (arr[i] - k) // (k + 1) + ((arr[i] - k) % (k + 1) >= 1)
		print(ans)
solve()


from math import inf as inf
from collections import *
import sys
from itertools import permutations
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = input().rstrip('\n')
	a = list(a)
	pr = -1000000000000
	c = 0
	r = 0
	i = 0
	flag = 0
	while i < n:
		if a[i] == '1':
			i += k + 1
		else:
			locflag = 0
			for j in range(max(0, i - k), i):
				if a[j] == '1':
					locflag = 1
					break
			pos = 0
			for j in range(i + 1, min(i + k + 1, n)):
				pos += 1
				if a[j] == '1':
					locflag = 1
					break
			if locflag == 0:
				r += 1
				a[i] = '1'
				i += k + 1
				continue
			i += pos
	print(r)


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input()]
	res = 0
	pos = [n + k + 1] * n
	q = n + k + 1
	for j in range(n - 1, -1, -1):
		pos[j] = q
		if arr[j] == 1:
			q = j
	prev = -k - 1
	for j in range(n):
		if arr[j] == 1:
			prev = j
		elif pos[j] - j > k and j - prev > k:
			res += 1
			prev = j
	print(res)


for test in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	res = 0
	i = 0
	while i < n:
		j = i + 1
		while j < n and s[j] != '1':
			j += 1
		lenn = j - i
		if s[i] == '1':
			left = k
			lenn -= 1
		else:
			left = 0
		if j < n and s[j] == '1':
			right = k
		else:
			right = 0
		lenn -= left + right
		if lenn > 0:
			res += (lenn + k) // (k + 1)
		i = j
	print(res)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2
from math import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	b = list(input())
	ans = 0
	ind = []
	for i in range(n):
		if b[i] == '1':
			ind.append(i)
	if len(ind) == 0:
		print(ceil(n / (k + 1)))
	else:
		ind.insert(0, -1)
		ind.append(n)
		count = []
		for i in range(1, len(ind)):
			count.append(ind[i] - ind[i - 1] - 1 - k - k)
		count[0] += k
		count[-1] += k
		for i in count:
			if i >= 0:
				ans += ceil(i / (k + 1))
		print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	last1 = n - 1
	numbers = 1
	for i in range(n - 1, -1, -1):
		if s[i] == '0':
			if last1 - i > k:
				numbers += 1
				last1 = i
		else:
			if last1 - i <= k:
				numbers -= 1
			last1 = i
	print(numbers)


import sys
input = sys.stdin.readline
from bisect import bisect_left
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, input().rstrip()))
	p = []
	for (i, v) in enumerate(s):
		if v:
			p.append(i)
	r = 0
	i = 0
	while i < len(s):
		v = s[i]
		if v == 0:
			pp = bisect_left(p, i)
			if pp == len(p) or p[pp] > i + k:
				r += 1
				i += k
		else:
			i += k
		i += 1
	print(r)


import sys
input = lambda : sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline

def I():
	return list(map(int, inp().split()))
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	s = input()
	cnt = [-(k + 1)]
	for i in range(len(s)):
		if s[i] == '1':
			cnt.append(i)
	cnt.append(len(s) + k)
	ans = 0
	for i in range(len(cnt) - 1):
		ans += (cnt[i + 1] - cnt[i] - 1 - k) // (k + 1)
	print(ans)


def nFreeTablesMax(lengthOfTables, distance, tables):
	space = distance + 1
	iFirst = tables.find('1')
	if iFirst == -1:
		return 1 + (lengthOfTables - 1) // space
	iLast = tables.rfind('1')
	return sum(map(lambda x: max(len(x) - distance, 0) // space, tables[iFirst + 1:iLast].split('1'))) + iFirst // space + (lengthOfTables - 1 - iLast) // space

def testCase_1367c():
	return (*map(int, input().split(' ')), input())
nTestCases = int(input())
testCases = tuple((testCase_1367c() for testCase in range(nTestCases)))
[print(nFreeTablesMax(*testCase)) for testCase in testCases]


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	c = k
	p = 2 * k + 1
	res = 0
	for i in range(len(s)):
		if s[i] == '0':
			c += 1
		else:
			c = 0
		if c == p:
			res += 1
			c = k
	if c >= k + 1:
		res += 1
	print(res)


from math import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	count = 0
	t = 0
	tables = 0
	if n == 1 and a[0] == 1:
		print(0)
	elif n == 1 and a[0] == 0:
		print(1)
	for i in a:
		if i == '0':
			count += 1
		else:
			t += 1
			if t == 1:
				if count - k > 0:
					tables += ceil((count - k) / (k + 1))
			elif count - 2 * k > 0:
				tables += ceil((count - 2 * k) / (k + 1))
			count = 0
	if t == 0:
		tables += ceil(count / (k + 1))
	elif count - k > 0:
		tables += ceil((count - k) / (k + 1))
	print(tables)


class Segtree:

	def __init__(self, arr):
		self.n = len(arr)
		self.a = arr
		self.t = [0] * (4 * self.n)

	def build(self, v, l, r):
		if r - l == 1:
			self.t[v] = self.a[l]
			return
		m = (r + l) // 2
		self.build(2 * v + 1, l, m)
		self.build(2 * v + 2, m, r)
		self.t[v] = self.t[2 * v + 1] + self.t[2 * v + 2]

	def change(self, v, l, r, pos, val):
		if r - l == 1:
			self.t[v] = val
			self.a[pos] = val
			return
		m = (r + l) // 2
		if pos < m:
			self.change(2 * v + 1, l, m, pos, val)
		else:
			self.change(2 * v + 2, m, r, pos, val)
		self.t[v] = self.t[2 * v + 1] + self.t[2 * v + 2]

	def ask(self, v, l, r, askl, askr):
		if l >= askl and r <= askr:
			return self.t[v]
		elif askr <= l or askl >= r:
			return 0
		else:
			m = (r + l) // 2
			return self.ask(2 * v + 1, l, m, askl, askr) + self.ask(2 * v + 2, m, r, askl, askr)

def solve():
	(n, k) = [int(x) for x in input().split()]
	s = [int(x) for x in input()]
	st = Segtree(s)
	st.build(0, 0, st.n)
	ans = 0
	for i in range(len(st.a)):
		if st.a[i] == 0:
			to_l = st.ask(0, 0, st.n, max(i - k, 0), i + 1)
			to_r = st.ask(0, 0, st.n, i, min(i + k + 1, n))
			if to_l == 0 and to_r == 0:
				ans += 1
				st.change(0, 0, st.n, i, 1)
	print(ans)
[solve() for i in range(int(input()))]


import math
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	l = list(s)
	l1 = []
	for i in range(len(l)):
		if l[i] == '1':
			l1.append(i)
	if len(l1) == 0:
		num = math.ceil(n / (m + 1))
		print(num)
	else:
		val = l1[0] // (m + 1)
		for i in range(1, len(l1)):
			num = l1[i] - l1[i - 1] - 1 - 2 * m
			val = val + math.ceil(num / (m + 1))
		val = val + (n - 1 - l1[-1]) // (m + 1)
		print(val)


for i in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	t = [len(v) for v in input().split('1')]
	t[0] += k
	t[-1] += k
	print(sum((max(0, (v + 1) // (k + 1) - 1) for v in t)))


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree1:

	def __init__(self, data, default=9999999, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if '1' not in s:
		print(int(math.ceil(len(s) / (k + 1))))
		continue
	one = []
	for i in range(n):
		if s[i] == '1':
			one.append(i)
	ans = one[0] // (k + 1)
	for j in range(1, len(one)):
		c = (one[j] - one[j - 1]) // (k + 1)
		ans += max(0, c - 1)
	ans += math.ceil(max(0, n - one[-1] - k - 1) / (k + 1))
	print(int(ans))


t = int(input())
for _ in range(t):
	(tables, dist) = list(map(int, input().split()))
	s = str(input())
	ans = 0
	tInd = [x for x in range(len(s)) if s[x] == '1']
	if len(tInd) == 0:
		ans = (tables - 1) // (dist + 1) + 1
		print(ans)
		continue
	else:
		if tInd[0] != 0 and tInd[0] - dist >= 1:
			ans += (tInd[0] - dist - 1) // (dist + 1) + 1
		if tInd[-1] != len(s) - 1 and tables - 1 - tInd[-1] - dist >= 1:
			ans += (tables - 1 - tInd[-1] - dist - 1) // (dist + 1) + 1
		if len(tInd) > 1:
			for i in range(len(tInd) - 1):
				i1 = tInd[i]
				i2 = tInd[i + 1]
				ans += (i2 - i1 - 1 - 2 * dist - 1) // (dist + 1) + 1
		print(ans)


import sys
import math
import heapq
from collections import defaultdict, deque
input = sys.stdin.readline

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
for i in range(r()):
	(n, k) = rm()
	a = list(input())
	intercnt = cnt = ones = 0
	firstOne = False
	for i in range(n):
		if a[i] == '0':
			intercnt += 1
		elif a[i] == '1':
			if not firstOne:
				intercnt -= k
				cnt += intercnt // (k + 1) + (1 if intercnt % (k + 1) != 0 else 0)
				firstOne = True
				intercnt = 0
			else:
				intercnt -= 2 * k
				cnt += intercnt // (k + 1) + (1 if intercnt % (k + 1) != 0 else 0)
				intercnt = 0
	if intercnt != 0:
		if firstOne:
			intercnt -= k
		cnt += intercnt // (k + 1) + (1 if intercnt % (k + 1) != 0 else 0)
	print(cnt)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(input())
	s = {}
	c = 0
	ans = 0
	if '1' not in l:
		l[0] = '1'
		ans = 1
	if '1' not in l[:k + 1]:
		l[0] = '1'
		ans = 1
	if '1' not in l[-k - 1:]:
		l[-1] = '1'
		ans += 1
	for i in range(k, len(l) - k - 1):
		if '1' not in l[i - k:i + k + 1]:
			l[i] = '1'
			ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = tuple((int(i) for i in input().split()))
	string = input()
	dp = [0 if string[0] == '1' else 1]
	c = 0
	for i in range(1, len(string)):
		if string[i] == '1':
			c = 0
			if i - k - 1 >= 0:
				dp.append(dp[i - k - 1])
			else:
				dp.append(0)
		else:
			c += 1
			dp.append(dp[i - 1])
			if c > k:
				dp[-1] += 1
				c = 0
	print(dp[-1])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input()]
	inds = []
	inds.append(-1 - k)
	for i in range(len(a)):
		if a[i] == 1:
			inds.append(i)
	inds.append(n + k)
	ans = 0
	for i in range(len(inds) - 1):
		dist = inds[i + 1] - inds[i]
		dist -= 1 + k
		if dist >= k + 1:
			ans += dist // (k + 1)
	print(ans)


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	things = list(map(int, list(input())))
	remaining = 0
	count = 0
	for y in range(len(things)):
		if things[y] == 1:
			remaining = k
		elif remaining > 0:
			remaining -= 1
			things[y] = 2
	things = things[::-1]
	for y in range(len(things)):
		if things[y] == 1:
			remaining = k
		elif things[y] == 2:
			remaining -= 1
		elif remaining > 0:
			remaining -= 1
			things[y] = 2
		else:
			count += 1
			remaining = k
	print(count)


def contiguous(size, k):
	return max(0, (size + 1) // (k + 1) - 1)

def solve(n, k, tab):
	tab = '1' + '0' * k + tab + '0' * k + '1'
	ans = 0
	cons = 0
	for el in tab:
		if el == '0':
			cons += 1
		else:
			ans += contiguous(cons, k)
			cons = 0
	return ans
t = int(input())
for test in range(t):
	(n, k) = [int(i) for i in input().split()]
	tab = input()
	print(solve(n, k, tab))


input = __import__('sys').stdin.readline
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input().strip()
	ans = 0
	if s.count('0') == len(s):
		for i in range(0, n, k + 1):
			ans += 1
		print(ans)
		continue
	cnt = 0
	cnts = []
	for x in s:
		if x == '0':
			cnt += 1
		else:
			cnts.append(cnt)
			cnt = 0
	cnts.append(cnt)
	for i in range(len(cnts)):
		if 0 < i and i < len(cnts) - 1:
			cnts[i] -= 2 * k
		else:
			cnts[i] -= k
		ans += max(0, (cnts[i] - 1) // (k + 1) + 1)
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().strip().split(' '))
	arr = list(map(int, list(input().strip())))
	ans = 0
	pos = []
	i = 0
	while i < n:
		if i == 0 and arr[i] == 0 or arr[i] == 1:
			run = 0
			if arr[i] == 0:
				run = 1
			i += 1
			while i < n and arr[i] != 1:
				run += 1
				i += 1
			pos.append(run)
		else:
			i += 1
	if len(pos) == 1 and arr[0] == 0 and (arr[-1] == 0):
		top = pos.pop(0)
		ans += 1
		top -= 1
		ans += top // (k + 1)
	elif arr[0] == 0:
		top = pos.pop(0)
		if top > k:
			ans += 1
			top -= 1
			top -= k
			ans += top // (k + 1)
	if pos and arr[-1] == 0:
		top = pos.pop()
		if top > k:
			ans += 1
			top -= 1
			top -= k
			ans += top // (k + 1)
	for top in pos:
		if top > k:
			top -= k
			ans += top // (k + 1)
	print(ans)


from math import ceil
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = [int(i) for i in input()]
	ans = 0
	i = 0
	while i < n:
		if s[i] == 0:
			ct = 1
			j = i + 1
			while j < n and s[j] == 0:
				ct += 1
				j += 1
			ct -= 2 * k
			if i == 0:
				ct += k
			if j == n:
				ct += k
			ans += max(0, int(ceil(ct / (k + 1))))
			i = j
		else:
			i += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	al = input()
	first1 = -1
	last1 = -1
	distBetween = []
	previous1 = -1
	for i in range(n):
		if al[i] == '0':
			continue
		else:
			if first1 == -1:
				first1 = i
			last1 = i
			if previous1 != -1:
				distBetween.append(i - previous1)
			previous1 = i
	if first1 != -1:
		additionalTable = 0
		additionalTable += first1 // (k + 1)
		additionalTable += (n - 1 - last1) // (k + 1)
		for elem in distBetween:
			additionalTable += elem // (k + 1) - 1
		print(additionalTable)
	else:
		print((n - 1) // (k + 1) + 1)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	sup = []
	start = 0
	rank = 0
	res = 0
	for i in range(n):
		if s[i] == '1':
			if rank == 0:
				res += (i - start) // (k + 1)
			else:
				res += math.ceil((i - start - 2 * k) / (k + 1))
			start = i + 1
			rank += 1
		elif i == n - 1:
			temp = i - start + 1
			if rank == 0:
				res += math.ceil(temp / (k + 1))
			else:
				res += temp // (k + 1)
	print(res)


t = int(input())
from bisect import bisect_left
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	occupied = [i for i in range(n) if s[i] == '1']
	new_occ = []
	for i in range(n):
		if occupied:
			ind1 = bisect_left(occupied, i)
			if ind1 < len(occupied) and occupied[ind1] == i:
				continue
			if ind1 == 0:
				left_diff1 = True
				right_diff1 = abs(i - occupied[ind1]) > k
			elif ind1 == len(occupied):
				left_diff1 = abs(i - occupied[-1]) > k
				right_diff1 = True
			else:
				left_diff1 = abs(i - occupied[ind1 - 1]) > k
				right_diff1 = abs(i - occupied[ind1]) > k
			if not (left_diff1 and right_diff1):
				continue
		if new_occ:
			left_diff2 = abs(new_occ[-1] - i) > k
			if not left_diff2:
				continue
		new_occ.append(i)
	print(len(new_occ))


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	a = []
	s = input()
	for i in range(len(s)):
		a.append(int(s[i:i + 1]))
	pref = [0 for i in range(n)]
	pref2 = [0 for i in range(n)]
	pref[0] = a[0]
	for i in range(1, len(a)):
		pref[i] = pref[i - 1] + a[i]
	i = 0
	ans = 0
	while i < len(a):
		if pref[i] == pref[max(0, i - k)] and pref[i] == pref[min(n - 1, i + k)] and (a[i] != 1) and (a[max(0, i - k)] != 1) and (a[min(n - 1, i + k)] != 1):
			ans += 1
			i += k + 1
		else:
			i += 1
	print(ans)


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	R = input()
	Z = 0
	ans = 0
	step = 0
	for elt in R:
		if elt == '0':
			Z += 1
		else:
			if step == 0:
				ans += max(0, Z // (K + 1))
				step += 1
			else:
				ans += max(0, (Z - K) // (K + 1))
			Z = 0
	if step == 1:
		ans += Z // (K + 1)
	else:
		ans += 1 + (Z - 1) // (K + 1)
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = '0' * k + input() + '0' * k
	groups = s.split('1')
	total = 0
	for g in groups:
		total += max((len(g) - k) // (k + 1), 0)
	print(total)


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def main():

	def solve():
		(n, k) = map(int, input().split())
		ss = input()
		count = 0
		last = -k - 1
		for i in range(n):
			if ss[i] == '1':
				if i - last <= k:
					count -= 1
				last = i
			elif i - last > k:
				count += 1
				last = i
		print(count)
	t = int(input())
	for _ in range(t):
		solve()
main()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	lis = list(input())
	ind = []
	count = 0
	for i in range(n):
		if lis[i] == '1':
			ind.append(count)
			count = 0
		elif lis[i] == '0':
			count += 1
			if i == n - 1:
				ind.append(count)
	if len(ind) == 1 and ind[0] == n:
		print((n - 1) // (k + 1) + 1)
	else:
		ans = 0
		for i in range(len(ind)):
			if i == 0 and lis[i] == '0':
				if ind[i] > k:
					ans += (ind[i] - k - 1) // (k + 1) + 1
			elif i == len(ind) - 1 and lis[-1] == '0':
				if ind[i] > k:
					ans += (ind[i] - k - 1) // (k + 1) + 1
			elif ind[i] > 2 * k:
				ans += (ind[i] - 2 * k - 1) // (k + 1) + 1
		print(ans)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	w = s.count('1')
	if w == 0:
		w = math.ceil(n / (k + 1))
		print(w)
		continue
	(a, b, p, q) = (-1, 0, 0, 0)
	for i in range(n):
		q = 0
		if s[i] == '1':
			if a == -1:
				p = i
				p = p - k
			else:
				p = i - a - 1
				p = p - 2 * k
			if p > 0:
				q = math.ceil(p / (k + 1))
			b += q
			a = i
	p = n - 1
	p = p - a - k
	if p > 0:
		q = math.ceil(p / (k + 1))
		b += q
	print(b)


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = '1' + '0' * k + input() + '0' * k + '1'
	count = []
	cur = 0
	for i in range(len(s)):
		if s[i] == '1':
			if cur:
				count += [cur]
			cur = 0
		else:
			cur += 1
	sum = 0
	for c in count:
		if c > 2 * k:
			sum += 1
			x = c - (2 * k + 1)
			sum += max(0, x // (k + 1))
	print(sum)


from sys import stdin
for _ in range(int(stdin.readline().rstrip())):
	(n, k) = map(int, stdin.readline().rstrip().split(' '))
	l = list(stdin.readline().rstrip())
	t = 0
	l_one = []
	for i in range(n):
		if l[i] == '1':
			l_one.append(i)
	if l_one:
		s = -(k + 1)
		t = 0
		for i in l_one:
			d = i - s - 1
			d = d - 2 * k
			if d > 0:
				t += 1 + (d - 1) // (k + 1)
			s = i
		if l_one[-1] != n - 1:
			d = n - l_one[-1] - 1
			d = d - k
			if d > 0:
				t += 1 + (d - 1) // (k + 1)
	else:
		t += 1 + (n - 1) // (k + 1)
	print(t)


def solve():
	(n, k) = list(map(int, input().split()))
	s = input()
	ans = 0
	i = 0
	k += 1
	while i < n:
		if s[i] == '1':
			i += k
		else:
			ok = True
			j = i + 1
			while j < i + k and j < n:
				if s[j] == '1':
					ok = False
					break
				j += 1
			if ok:
				ans += 1
			i = j
	return ans

def main():
	t = int(input())
	while t:
		print(solve())
		t -= 1
main()


from typing import *

def count_changes(table_setup: str, distance: int) -> int:
	changes_count = 0
	i = 0
	while i < len(table_setup):
		ch = table_setup[i]
		if ch == '0':
			for j in range(i + 1, min(i + distance + 1, len(table_setup))):
				if table_setup[j] == '1':
					i = j + distance + 1
					break
			else:
				changes_count += 1
				i += distance + 1
		else:
			i += distance + 1
	return changes_count
t = int(input())
for _ in range(t):
	(_, k) = map(int, input().split(' '))
	print(count_changes(input(), k))


import sys

def input():
	return sys.stdin.readline()[:-1]

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		s = [int(x) for x in input()]
		s = [0] * k + s + [0] * k
		ans = 0
		i = k
		while i < n + k:
			while s[i] == 1:
				i += 1
			flag = 1
			for l in range(k + 1):
				if s[i - l] == 1:
					flag = 0
					i = i - l + k + 1
					break
			if flag == 1:
				for r in range(k + 1):
					if s[i + r] == 1:
						flag = 0
						i = i + r + k + 1
						break
			if flag == 1:
				s[i] = 1
				ans += 1
				i += k + 1
		print(ans)
main()


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = str(input())
	a = []
	for i in range(n):
		if l[i] == '1':
			a.append(i)
	(c1, c2, c3) = (0, 0, 0)
	for i in range(len(a) - 1):
		if a[i + 1] - a[i] - 1 > 2 * k:
			c1 += math.ceil((a[i + 1] - a[i] - 1 - 2 * k) / (k + 1))
	if a:
		if a[0] > k:
			c2 = a[0] - k
			c2 = math.ceil(c2 / (k + 1))
		if n - 1 - a[-1] > k:
			c3 = n - 1 - a[-1] - k
			c3 = math.ceil(c3 / (k + 1))
	else:
		c1 = math.ceil(n / (k + 1))
	print(c1 + c2 + c3)


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	c = 0
	arr = []
	for i in range(n):
		if s[i] == '1':
			arr.append(i)
	ans = 0
	for i in range(len(arr) - 1):
		if arr[i + 1] - arr[i] - 1 > 2 * k:
			temp = 0
			for ll in range(arr[i] + 1, arr[i + 1] - k):
				temp += 1
				if temp == k + 1:
					ans += 1
					temp = 0
	temp = 0
	if len(arr) == 0:
		temp = 0
		ans = 1
		for i in range(1, n):
			temp += 1
			if temp == k + 1:
				ans += 1
				temp = 0
		print(ans)
		continue
	for i in range(arr[0] - 1, -1, -1):
		temp += 1
		if temp == k + 1:
			ans += 1
			temp = 0
	temp = 0
	for i in range(arr[-1] + 1, n):
		temp += 1
		if temp == k + 1:
			ans += 1
			temp = 0
	print(ans)


t = int(input())
rez = []
for i in range(t):
	A = input().split()
	n = int(A[0])
	k = int(A[1])
	re = 0
	s = input()
	r = []
	l = 0
	for j in range(len(s)):
		if s[j] == '0':
			l += 1
		else:
			r.append(l)
			l = 0
	r.append(l)
	if len(r) == 1:
		re = 1
		re += int((r[0] - 1) // (k + 1))
		rez.append(re)
	else:
		if r[0] != 0:
			re += r[0] // (k + 1)
		for j in range(1, len(r) - 1):
			while r[j] >= 2 * k + 1:
				re += 1
				r[j] -= k + 1
		re += r[-1] // (k + 1)
		rez.append(re)
for i in range(len(rez)):
	print(rez[i])


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	(n, k) = list(map(int, stdin.readline().rstrip().split()))
	s = input()
	cur = -k - 1
	cnt = 0
	for i in range(n):
		if s[i] == '1':
			if i - cur <= k:
				cnt -= 1
			cur = i
		elif i - cur > k:
			cur = i
			cnt += 1
	print(cnt)


for i in range(int(input())):
	list1 = list(map(int, input().rstrip().split()))
	n = list1[0]
	k = list1[1]
	l = list(input())
	zero = []
	one = []
	for j in range(n):
		if l[j] == '1':
			one.append(j)
	j = 0
	x = 0
	count = 0
	while j < n:
		if x < len(one):
			if abs(one[x] - j) > k:
				count += 1
				j += k + 1
			else:
				j = one[x] + k + 1
				x += 1
		else:
			while j < len(l):
				count += 1
				j += k + 1
	print(count)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	s = input()
	last_1 = -1
	last_r = -1
	answ = 0
	i = 0
	while i < n:
		index = i + 1
		while index < n and s[index] != '1':
			index += 1
		l = index - i
		if s[i] == '1':
			l -= k + 1
		if index < n and s[index] == '1':
			l -= k
		if l > 0:
			answ += (l + k) // (k + 1)
		i = index
	print(answ)
	t -= 1


t = int(input())
for i in range(t):
	values = input()
	values = values.split(' ')
	n = int(values[0])
	k = int(values[1])
	tables = input()
	count = k
	result = 0
	for table in tables:
		if table == '0':
			count += 1
			if count >= 2 * k + 1:
				result += 1
				count = k
		else:
			count = 0
	if count >= k + 1:
		result += 1
	print(result)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	after = [float('inf')] * n
	if s[-1] == '1':
		after[-1] = n - 1
	for i in range(n - 2, -1, -1):
		if s[i] == '1':
			after[i] = i
		else:
			after[i] = after[i + 1]
	t = 0
	last = float('-inf')
	for i in range(n):
		if s[i] == '0' and i - last > k and (after[i] - i > k):
			t += 1
			last = i
		elif s[i] == '1':
			last = i
	print(t)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	seating = input()
	count = 0
	seating = list(seating)
	i = 0
	x = seating.count('1')
	left = [-1] * n
	right = [-1] * n
	pos = -1
	for i in range(n):
		if seating[i] == '1':
			pos = i
		left[i] = pos
	pos = -1
	for i in range(n - 1, -1, -1):
		if seating[i] == '1':
			pos = i
		right[i] = pos
	while i < n:
		if seating[i] == '0':
			if (left[i] == -1 or i - left[i] > k) and (right[i] == -1 or right[i] - i > k):
				count += 1
				i += k + 1
			else:
				i += 1
		else:
			i += 1
	print(count)


from math import *
from copy import *
from heapq import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from decimal import Decimal
from collections import Counter
from collections import defaultdict

def solve(s, k):
	n = len(s)
	ind = []
	for i in range(n):
		if s[i] == '1':
			ind.append(i)
	if s.count('1') == 0:
		ans = 0
		for i in range(0, n, k + 1):
			ans += 1
		return ans
	first = s.find('1') - k
	last = n - s.rfind('1') - k - 1
	add = max(0, ceil(first / (k + 1)))
	add += max(0, ceil(last / (k + 1)))
	for i in range(1, len(ind)):
		diff = ind[i] - ind[i - 1] - 1 - 2 * k
		add += max(0, ceil(diff / (k + 1)))
	return add
T = int(input())
for _ in range(T):
	(N, K) = list(map(int, stdin.readline().rstrip().split()))
	l = input()
	print(solve(l, K))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = input()
	sp = []
	ln = 0
	for i in range(len(s)):
		if s[i] == '1':
			sp.append(i)
	if not bool(sp):
		ln = len(s) // (k + 1)
		a = len(s) % (k + 1)
		if a != 0:
			ln += 1
	else:
		for i in range(len(sp)):
			if i == 0:
				dif = (sp[i] - k) // (k + 1)
				a = (sp[i] - k) % (k + 1)
				if dif >= 0:
					if a != 0:
						dif += 1
					ln += dif
			if i == len(sp) - 1:
				dif = (len(s) - 1 - sp[i] - k) // (k + 1)
				if dif >= 0:
					a = (len(s) - 1 - sp[i] - k) % (k + 1)
					if a != 0:
						dif += 1
					ln += dif
			if i > 0:
				dif = (sp[i] - sp[i - 1] - 1 - k * 2) // (k + 1)
				if dif >= 0:
					a = (sp[i] - sp[i - 1] - 1 - k * 2) % (k + 1)
					if a != 0:
						dif += 1
					ln += dif
	print(ln)


for _ in range(int(input())):
	(N, K) = list(map(int, input().split()))
	s = list(map(int, input()))
	index = []
	for i in range(N):
		if s[i] == 1:
			index.append(i)
	if len(index) == 0:
		ans = N // (K + 1)
		if N % (K + 1) != 0:
			ans += 1
		print(ans)
	else:
		ans = 0
		ans += index[0] // (K + 1)
		for i in range(1, len(index)):
			if index[i] - index[i - 1] > K:
				ans += (index[i] - index[i - 1] - K - 1) // (K + 1)
		if N - index[len(index) - 1] > K:
			if (N - index[-1] - K - 1) % (K + 1) != 0:
				ans += (N - index[-1] - K - 1) // (K + 1) + 1
			else:
				ans += (N - index[-1] - K - 1) // (K + 1)
		print(ans)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = input()
	zero = []
	one = []
	for i in range(len(arr)):
		if arr[i] == '0':
			zero.append(i)
		else:
			one.append(i)
	if n == k:
		if len(zero) == n:
			print(1)
		else:
			print(0)
	elif len(zero) == n:
		print(math.ceil(n / (k + 1)))
	elif len(one) == n:
		print(0)
	else:
		k = k
		cnt = 0
		ans = 0
		j = 1
		ss = len(one)
		for i in range(n):
			if arr[i] == '1':
				if i == 0:
					prev = i
					cnt += 1
					if cnt == ss:
						next = 0
					else:
						next = one[1]
				elif i == next:
					cnt += 1
					if cnt == ss:
						prev = next
						next = 0
					else:
						prev = next
						j += 1
						next = one[j]
			elif i == 0:
				j = 0
				prev = -1
				next = one[0]
				if abs(i - next) > k:
					ans += 1
					prev = i
			elif prev == -1:
				continue
			elif next == 0:
				if abs(i - prev) > k:
					ans += 1
					prev = i
			elif i == n - 1:
				if abs(i - prev) > k:
					ans += 1
					prev = i
			elif abs(i - prev) > k and abs(i - next) > k:
				ans += 1
				prev = i
		print(ans)


from sys import stdin

def fun(prev, final, k):
	if prev - 1 >= 0:
		prev += k
	if final + 1 != n:
		final = final - k
	li = [0 for j in range(final - prev + 1)]
	for j in range(0, len(li), k + 1):
		li[j] = 1
	if prev == 0 and final == n - 1:
		return max(sum(li), 1)
	return sum(li)
testcase = int(stdin.readline())
for i in range(testcase):
	(n, k) = map(int, stdin.readline().split())
	str1 = stdin.readline()
	li = [0 for j in range(n)]
	for p in range(n):
		li[p] = int(str1[p])
	j = 0
	str1 = li
	count = 0
	while j < n:
		if str1[j] == 0:
			prev = j
			while j < n and str1[j] == 0:
				j += 1
			count += fun(prev, j - 1, k)
		j += 1
	print(count)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = list(input())
	lis = [0] * n
	if s.count('0') == n:
		ans = n // (m + 1)
		if n % (m + 1):
			ans += 1
		print(ans)
	else:
		i = 0
		c = 0
		ans = 0
		while s[i] == '0':
			c += 1
			i += 1
		ans += c // (m + 1)
		j = n - 1
		c = 0
		while s[j] == '0':
			c += 1
			j -= 1
		ans += c // (m + 1)
		c = 0
		for k in range(i, j + 1):
			if s[k] == '1':
				ans += max(0, c - m) // (m + 1)
				c = 0
			else:
				c += 1
		print(ans)


def tables_available(n, k, string):
	libres = 0
	cont = 0
	ocupados = 0
	available = ['0'] * n
	for i in range(0, n):
		if string[i] == '1':
			available[i] = 'ocupado'
			for a in range(1, k + 1):
				if i - a >= 0 and available[i - a] != 'ocupado':
					available[i - a] = 'x'
				if i + a < n and available[i + a] != 'ocupado':
					available[i + a] = 'x'
	i = 0
	while i < n:
		if available[i] == '0':
			cont = cont + 1
			i = i + k + 1
		else:
			i = i + 1
	return cont
loop = int(input())
for i in range(loop):
	requirements = input()
	requirements = requirements.split()
	n = int(requirements[0])
	k = int(requirements[1])
	string = input()
	print(tables_available(n, k, string))


from pprint import pprint
import sys
import itertools

def countstrs(s):
	return [(k, len(list(g))) for (k, g) in itertools.groupby(s)]
import math
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = input()
	res = 0
	dat = countstrs(s)
	l = len(dat)
	for i in range(l):
		ignoreLeft = False
		ignoreRight = False
		if i == 0:
			ignoreLeft = True
		if i == l - 1:
			ignoreRight = True
		if dat[i][0] == '1':
			continue
		cnt = dat[i][1]
		if ignoreRight is False:
			cnt -= k
		if ignoreLeft is False:
			cnt -= k
		if cnt <= 0:
			continue
		res += math.ceil(cnt / (k + 1))
	print(res)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().rstrip().split()))
	nums = input()
	left = []
	right = []
	prev = float('inf')
	for i in range(len(nums)):
		if nums[i] == '1':
			left.append(0)
		elif len(left) == 0:
			left.append(float('inf'))
		else:
			left.append(left[-1] + 1)
	for i in range(len(nums) - 1, -1, -1):
		if nums[i] == '1':
			right.append(0)
		elif len(right) == 0:
			right.append(float('inf'))
		else:
			right.append(right[-1] + 1)
	right = right[::-1]
	place = False
	count = 0
	for i in range(len(left)):
		if place == True:
			if left[i] == 0:
				place = False
			else:
				left[i] = left[i - 1] + 1
		if k <= left[i] - 1 and k <= right[i] - 1:
			place = True
			count += 1
			left[i] = 0
	print(count)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	i = 0
	count = 0
	while i < n:
		if s[i] == '1':
			i = i + k + 1
			continue
		if s[i] == '0':
			j = i + 1
			state = 0
			while j < i + k + 1 and j < n:
				if s[j] == '1':
					state = 1
					break
				j += 1
			if state == 0:
				count += 1
				i = j
			else:
				i = j
	print(count)


from itertools import groupby
for T in range(int(input())):
	(N, K) = map(int, input().split())
	A = map(int, input())
	ans = 0
	groups = [(k, len(list(grp))) for (k, grp) in groupby(A)]
	for (i, (x, length)) in enumerate(groups):
		if x == 0:
			border = 2 - (i == 0) - (i == len(groups) - 1)
			length -= border * K
			ans += max((length + K) // (K + 1), 0)
	print(ans)


T = int(input())
for _ in range(T):
	(n, k) = list(map(int, input().split()))
	s = input()
	tot = 0
	f = [tot]
	for c in s:
		tot += c == '1'
		f.append(tot)
	t = list(s)
	ans = 0
	i = 0
	while i < n:
		l = max(0, i - k)
		r = min(n, i + k + 1)
		if t[i] == '0' and f[i + 1] - f[l] == 0 and (f[r] - f[i] == 0):
			ans += 1
			i += k + 1
		else:
			i += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, list(input())))
	pre = [0 for i in range(n)]
	pre[0] = s[0]
	for i in range(1, n):
		pre[i] = pre[i - 1] + s[i]
	i = 0
	ans = 0
	while i < n:
		if s[i] == 0:
			if pre[min(i + k, n - 1)] - pre[i] == 0 and (pre[i - 1] if i > 0 else 0) - (pre[i - k - 1] if i - k - 1 >= 0 else 0) == 0:
				ans += 1
				s[i] = 1
				i += k + 1
			else:
				i += 1
		else:
			i += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = input() + '1'
	m = r = 0
	for i in range(n + 1):
		if a[i] == '0':
			m += 1
		else:
			if i != m and i - 1 != n - 1:
				m -= k
			if m > 0:
				r += m // (k + 1)
			m = 0
	if a.count('1') == 1:
		r = n // (k + 1)
		if n % (k + 1) != 0:
			r += 1
	print(r)


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	S = input()
	diff = []
	count1 = 0
	for i in range(N):
		if S[i] == '1':
			count1 += 1
	if count1 == 0:
		print((len(S) + K) // (K + 1))
	else:
		cnt = 0
		for i in range(N):
			if S[i] == '1':
				diff.append(cnt)
				cnt = 0
			else:
				cnt += 1
		diff.append(cnt)
		ans = 0
		for i in range(len(diff)):
			if i == 0 or i == len(diff) - 1:
				ans += diff[i] // (K + 1)
			else:
				ans += max(0, (diff[i] - K) // (K + 1))
		print(ans)


from math import *
a = int(input())
for _ in range(a):
	(b, c) = map(int, input().split())
	l = input()
	x = []
	ans = 0
	for i in range(b):
		if l[i] == '1':
			x.append(i)
	if len(x) == 0:
		print(ceil(b / (c + 1)))
	else:
		for i in range(len(x)):
			if i == 0 and x[0] != 0:
				p = x[0] - c
				if p >= 0:
					ans += ceil(p / (c + 1))
			if i == len(x) - 1:
				if x[len(x) - 1] != b - 1:
					d = b - 1 - x[len(x) - 1] - c
					if d >= 0:
						ans += ceil(d / (c + 1))
			elif i != len(x) - 1:
				y = x[i + 1] - 1 - x[i] - 2 * c
				if y >= 0:
					ans += ceil(y / (c + 1))
		print(ans)


def cnt(n, k):
	base = 0
	cn = 1
	while True and n > 1:
		if n - cn >= (cn + 1) * k:
			base = cn
			cn += 1
		else:
			break
	return base

def social(s, k):
	ans = 0
	ind = [i for i in range(len(s)) if s[i] == '1']
	if s.count('1') == 0:
		if len(s) - 1 - 1 >= k:
			ind += [0, len(s) - 1]
			ans += 2
		else:
			ans += 1
			return ans
	if len(ind) >= 1:
		t = ind[-1]
		if len(s) - 1 - t - 1 >= k:
			ind += [len(s) - 1]
			ans += 1
		t = ind[0]
		if t - 0 - 1 >= k:
			ind = [0] + ind
			ans += 1
	for i in range(0, len(ind) - 1):
		ans += cnt(ind[i + 1] - ind[i] - 1, k)
	return ans
for i in range(int(input())):
	(a, b) = map(int, input().strip().split())
	x = input()
	print(social(x, b))


t = int(input())
for i in range(0, t):
	nk = input().split()
	s = str(input())
	n = int(nk[0])
	k = int(nk[1])
	count = 0
	M = []
	for i in range(0, n):
		if s[i] == '1':
			M.append(i)
	if len(M) == 0:
		print((n + k) // (k + 1))
	elif len(M) == 1:
		rs = (n - 1 - M[0]) // (k + 1)
		ls = M[0] // (k + 1)
		print(rs + ls)
	else:
		for i in range(1, len(M)):
			temp = M[i] - M[i - 1]
			count += -1 + temp // (k + 1)
		count += M[0] // (k + 1) + (n - 1 - M[-1]) // (k + 1)
		print(count)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	str = input()
	(l, flag, ans) = (0, 0, 0)
	for i in range(len(str)):
		if str[i] == '1':
			if i != l:
				if flag:
					ans += (i - l) // (k + 1) - 1
				else:
					ans += (i - l) // (k + 1)
				l = i
			flag = 1
	if l != len(str) - 1:
		ans += (n - 1 - l) // (k + 1)
	if flag == 0:
		ans = 1 + (n - 1) // (k + 1)
	print(ans)


for i in range(int(input())):
	(n, k) = [int(k) for k in input().split()]
	arr = input()
	flag = k
	ans = 0
	for ele in arr:
		if ele == '0':
			flag += 1
		else:
			flag = 0
		if flag == 2 * k + 1:
			ans += 1
			flag = k
	if flag >= k + 1:
		ans += 1
	print(ans)


def main2():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		s = list(input())
		acc = 0
		b = []
		for i in range(len(s)):
			if s[i] == '1':
				b.append(i)
		j = 0
		i = 0
		while i < n:
			if s[i] == '0' and len(b) != 0 and (b[j] > i) and (b[j] - i > k):
				acc += 1
				i += k + 1
			elif len(b) != 0 and (not abs(b[j] - i) > k):
				i += 1
			elif s[i] == '1':
				i += k + 1
			elif j + 1 < len(b) and b[j] < i < b[j + 1] and (abs(i - b[j]) > k < abs(b[j + 1] - i)):
				acc += 1
				i += k + 1
			elif j + 1 < len(b) and b[j] < i < b[j + 1]:
				i += 1
			elif j < len(b) - 1 and (not b[j] < i < b[j + 1]):
				j += 1
			elif j < len(b) and abs(i - b[j]) > k:
				i += k + 1
				acc += 1
			elif len(b) == 0:
				i += k + 1
				acc += 1
			else:
				i += 1
		print(acc)
main2()


def abc(x, k):
	if x <= 0:
		return 0
	ans = x // (k + 1)
	if x % (k + 1):
		ans += 1
	return ans
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	if '1' not in s:
		print(abc(n, k))
		continue
	ans = 0
	i = 0
	while i < n and s[i] != '1':
		i += 1
	ans += abc(i - k, k)
	x = i
	i += 1
	while i < n:
		if s[i] == '1':
			ans += abc(i - k - (x + k) - 1, k)
			x = i
			i += 1
		else:
			i += 1
	ans += abc(n - x - k - 1, k)
	print(ans)


from sys import stdin
import math
a = int(stdin.readline())
for k in range(0, a):
	A = list(map(int, stdin.readline().split()))
	B = stdin.readline()
	K = A[1]
	temp = 0
	header = 0
	k = 0
	sum = 0
	for y in range(0, len(B) - 1):
		sum += int(B[y])
	if B[0] != '1':
		while k <= len(B) - 2 and B[k] == '0':
			temp += 1
			k += 1
	header = temp
	temp = 0
	L = list()
	footer = 0
	for u in range(k + 1, len(B) - 1):
		if B[u] == '0':
			temp += 1
		else:
			if temp > 0:
				L.append(temp)
			temp = 0
		if u == len(B) - 2:
			if temp > 0:
				footer = temp
	ans = header // (K + 1) + footer // (K + 1)
	for u in L:
		if u <= K:
			ans += 0
		else:
			ans += (u - K) // (1 + K)
	if sum == 0 and ans == 0:
		print(1)
	elif sum == 0 and len(L) == 0:
		print(int(math.ceil(header / (K + 1))))
	else:
		print(int(ans))


n = input
for i in [0] * int(n()):
	m = int(n().split()[1])
	h = '0' * m
	print(sum((max(0, len(p) - m) // (m + 1) for p in (h + n() + h).split('1'))))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	t = input()
	x = 0
	c = 0
	f = 0
	if '1' not in t:
		print((n - 1) // (k + 1) + 1)
		continue
	(fo, lo) = (t.index('1'), len(t) - 1 - t[::-1].index('1'))
	for i in range(fo + 1, lo + 1):
		if t[i] == '0' and f == 0:
			f = 1
			c = 1
		elif t[i] == '0' and f == 1:
			c += 1
		else:
			f = 0
			if c != 0:
				x += (c - k) // (k + 1)
	x += fo // (k + 1)
	x += (n - 1 - lo) // (k + 1)
	print(x)


def main():
	t = int(input())
	for i in range(t):
		solve()

def solve():
	(n, k) = list(map(int, input().split(' ')))
	arr = [int(i) for i in input()]
	cant_place = set()
	current = sum(arr)
	if n == k:
		print(1 - current)
		return
	if current == 0:
		for i in range(0, len(arr), k + 1):
			arr[i] = 1
		print(sum(arr))
		return
	for (index, i) in enumerate(arr):
		if i == 0:
			continue
		for j in range(1, k + 1):
			cant_place.add(index + j)
			cant_place.add(index - j)
	for i in range(len(arr)):
		if arr[i] == 0 and i not in cant_place:
			arr[i] = 1
			for j in range(1, k + 1):
				cant_place.add(i + j)
				cant_place.add(i - j)
	print(sum(arr) - current)
main()


arg = int(input())
for _ in range(0, arg):
	(n, k) = map(int, input().strip().split())
	l = list(input().strip())
	window = k
	r = 0
	flag9 = 0
	for i in range(0, n):
		if l[i] == '0':
			if i == n - 1:
				window += k
			window += 1
		if window >= 2 * k + 1:
			r += 1
			window = k
		if l[i] == '1':
			window = 0
			flag9 = 1
	if flag9 == 0 and r == 0:
		r += 1
	print(r)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	l = []
	for i in range(0, n):
		if s[i] == '1':
			l.append(i)
	prev = -1
	next = -1
	if len(l) != 0:
		next = l[0]
	res = 0
	for i in range(0, n):
		if s[i] == '0':
			if prev == -1 and next == -1:
				res += 1
				prev = i
			elif prev == -1:
				if next - i > k:
					res += 1
					prev = i
			elif next == -1:
				if i - prev > k:
					res += 1
					prev = i
			elif i - prev > k and next - i > k:
				res += 1
				prev = i
		else:
			prev = next
			l.pop(0)
			if len(l) == 0:
				next = -1
			else:
				next = l[0]
	print(res)


import math
for _ in range(int(input())):
	(n, k) = [int(_) for _ in input().split()]
	S = input()
	A = []
	for _ in range(n):
		if S[_] == '1':
			A.append(_)
	c = 0
	for _ in range(len(A) - 1):
		x = (A[_ + 1] - A[_]) // (k + 1) - 1
		if x > 0:
			c += x
	if len(A) == 0:
		print(math.ceil(n / (k + 1)))
	elif len(A) == 1:
		print(A[0] // (k + 1) + (n - A[0] - 1) // (k + 1))
	else:
		c += A[0] // (k + 1)
		c += (n - A[-1] - 1) // (k + 1)
		print(c)


import math
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	table = list(input())
	for j in range(n):
		if table[j] == '1':
			for l in range(1, k + 1):
				if j - l >= 0:
					if table[j - l] == '0':
						table[j - l] = 'X'
				if j + l <= n - 1:
					if table[j + l] == '0':
						table[j + l] = 'X'
	seat = 0
	for j in range(n):
		if table[j] == '0':
			seat = seat + 1
			table[j] = '1'
			for m in range(1, k + 1):
				if j + m <= n - 1:
					if table[j + m] == '0':
						table[j + m] = 'X'
	print(seat)


import sys
input = sys.stdin.readline
from collections import *
from bisect import *
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()[:-1]
	if '1' not in s:
		print(1 + (n - 1) // (k + 1))
		continue
	l = []
	for i in range(n):
		if s[i] == '1':
			l.append(i)
	l.append(10 ** 18)
	ans = 0
	prev = -10 ** 18
	for i in range(n):
		if s[i] == '1':
			prev = i
		else:
			nex = l[bisect_left(l, i)]
			if i - prev > k and nex - i > k:
				ans += 1
				prev = i
	print(ans)


def sd(l, n, k):
	i = 0
	c = 0
	if n == k and l.count('1') == 0:
		print(1)
		return
	while i < n:
		if l[i] == '1':
			i = i + k + 1
		elif i == n - 1:
			if l[len(l) - 1] == '0' and l[len(l) - 2:len(l) - 2 - k:-1].count('0') == k:
				c = c + 1
			i = i + 1
		elif l[i] == '0':
			if i + 1 + k <= n and l[i + 1:i + 1 + k].count('0') == k:
				c = c + 1
				i = i + k + 1
			else:
				i = i + 1
	print(c)
	return
n = int(input())
for i in range(n):
	(n, k) = map(int, input().split(' '))
	s = input()
	l = list(s)
	sd(l, n, k)


t = int(input())
for i in range(t):
	s = input().split()
	n = int(s[0])
	k = int(s[1])
	s = input()
	r = s[::-1]
	a = s.find('1')
	b = r.find('1')
	if a == -1:
		p = n % (k + 1)
		if p:
			print(n // (k + 1) + 1)
		else:
			print(n // (k + 1))
		continue
	j = a
	count = 0
	while j + k + 1 < n - b - 1:
		flag = 0
		if j + 2 * (k + 1) <= n:
			for h in range(j + k + 1, j + 2 * (k + 1)):
				if s[h] == '1':
					j = h
					flag = 1
					break
		else:
			break
		if flag == 1:
			continue
		else:
			count += 1
			j = j + k + 1
			continue
	count += a // (k + 1)
	count += b // (k + 1)
	print(count)


t = int(input())

def fun(n, k, a):
	ans = 0
	on = -1
	i = 0
	while i < n:
		if a[i] == '1':
			on = i
			i += 1
		elif a[i] == '0' and (i - on > k or on == -1):
			l = i * 2
			while i < n:
				if a[i] == '1':
					break
				if i - l / 2 > k:
					break
				i += 1
			if i - l / 2 > k:
				ans += 1
				if i < n and a[i] == '1':
					on = i * 2
					on /= 2
				else:
					oneo = l / 2
			if i - l / 2 <= k and i == n:
				ans += 1
		else:
			i += 1
	print(ans)
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = input()
	fun(n, k, a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	str = input()
	(ans, prev) = (0, 0)
	if str[0] == '0':
		ans += 1
	for idx in range(1, len(str)):
		if str[idx] == '1':
			if idx - prev <= k:
				ans -= 1
			prev = idx
		elif idx - prev > k:
			ans += 1
			prev = idx
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	c = []
	s = list(s)
	for i in range(len(s)):
		if s[i] == '1':
			c.append(i)
	i = 0
	if len(c) != 0:
		init = 0
		prev = c[0]
		while init <= prev - k - 1:
			count += 1
			init += k + 1
		while i < len(c) - 1:
			if prev + k + 1 <= c[i + 1] - k - 1:
				count += 1
				prev = prev + k + 1
			else:
				prev = c[i + 1]
				i += 1
		init = c[len(c) - 1]
		while init + k + 1 < n:
			count += 1
			init = init + k + 1
	else:
		for i in range(0, n, k + 1):
			count += 1
	print(count)


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().rstrip().split())
	s = input().rstrip()
	num = 0
	mov = 0
	for i in range(N):
		if s[i] == '0':
			if mov == 0:
				num += 1
				mov = K
			else:
				mov -= 1
		elif s[i] == '1':
			if mov != 0:
				num -= 1
			mov = K
	print(num)


import math

def solve():
	(n, k) = map(int, input().split())
	s = input()
	if s.count('1') == 0:
		print(math.ceil(n / (k + 1)))
	else:
		(cnt, ans) = (0, 0)
		i = 0
		while i < n:
			if s[i] == '0':
				cnt += 1
			else:
				ans += cnt // (k + 1)
				cnt = 0
				break
			i += 1
		while i < n:
			if s[i] == '0':
				cnt += 1
			else:
				ans += max(0, (cnt + 1) // (k + 1) - 1)
				cnt = 0
			i += 1
		ans += cnt // (k + 1)
		print(ans)
t = int(input())
for _ in range(t):
	solve()


for i in range(int(input())):
	(a, b) = map(int, input().split())
	array = list(map(int, input()))
	c = 0
	if a < b + 2:
		print(0) if 1 in array else print(1)
	else:
		if 1 not in array[:b + 1]:
			array[0] = 1
			c += 1
		if 1 not in array[a - (b + 1):]:
			array[-1] = 1
			c += 1
		for i in range(b + 1, a - (b + 1)):
			if 1 not in array[i - b:i + b + 1]:
				array[i] = 1
				c += 1
		print(c)


t = int(input())
for _ in range(t):
	(n, d) = map(int, input().split())
	s = input()
	one = []
	mark = [True] * n
	for i in range(n):
		if s[i] == '1':
			one.append(i)
			mark[i] = False
	for i in one:
		st = i + 1
		ct = 0
		while ct < d and st < n:
			ct += 1
			mark[st] = False
			st += 1
		st = i - 1
		ct = 0
		while ct < d and st >= 0:
			ct += 1
			mark[st] = False
			st -= 1
	adj = []
	ct = 0
	for i in range(n):
		if mark[i]:
			ct += 1
		else:
			if ct != 0:
				adj.append(ct)
			ct = 0
	if ct != 0:
		adj.append(ct)
	ans = 0
	for i in adj:
		j = 0
		while j < i:
			j += 1
			j += d
			ans += 1
	print(ans)


from sys import stdin
input = lambda : stdin.readline().strip()
char = [chr(i) for i in range(97, 123)]
CHAR = [chr(i) for i in range(65, 91)]
mp = lambda : list(map(int, input().split()))
INT = lambda : int(input())
rn = lambda : range(INT())
from math import ceil, sqrt, factorial, gcd, log
for _ in rn():
	(n, k) = mp()
	l = input()
	flag = 0
	c = 0
	ans = 0
	for i in l:
		if i == '0':
			c += 1
		else:
			if flag == 0:
				ans += c // (1 + k)
				flag = 1
			else:
				ans += (c - k) // (1 + k)
			c = 0
	if c != 0:
		if flag == 1:
			ans += c // (1 + k)
		else:
			ans += ceil(c / (1 + k))
	if n == k and flag == 0:
		ans = 1
	print(ans)


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	(n, m) = map(int, input().split())
	s = input().split()[0]
	pre = [0] * (n + 1)
	pre[1] = int(s[0])
	for i in range(2, n + 1):
		pre[i] = pre[i - 1] + int(s[i - 1])
	cou = 0
	su = 0
	i = 1
	while i <= n:
		if s[i - 1] == '0':
			ind = max(i - m - 1, 0)
			if pre[i] == pre[ind]:
				ind = min(n, i + m)
				if pre[ind] == pre[i]:
					cou += 1
					i += m + 1
					continue
		i += 1
	print(cou)
	t -= 1


t = int(input())
for hh in range(0, t):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	s = list(s)
	a = [0] * (n + 1)
	xx = [0] * (n + 1)
	for i in range(0, len(s)):
		if s[i] == '1':
			a[i] = 1
	xx[0] = a[0]
	for i in range(1, n + 1):
		xx[i] = xx[i - 1] + a[i]
	i = 0
	ans = 0
	yy = 0
	while i < n:
		if s[i] == '0':
			uu = min(n - 1, i + k)
			pp = max(0, i - k)
			if pp == 0:
				rr = xx[uu] + yy
			else:
				rr = xx[uu] + yy - xx[pp - 1]
			if rr == 0:
				ans += 1
				s[i] = '1'
				a[i] = 1
				yy += 1
		xx[i] += yy
		i += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(str(input()))
	ans = 0
	if a == ['0'] * n:
		a[0] = '1'
		ans += 1
	mark = []
	for i in range(n):
		if a[i] == '1':
			mark.append(i + 1)
	zinb = []
	for i in range(len(mark) - 1):
		zinb.append(mark[i + 1] - mark[i] - 1)
	bs = mark[0] - 1
	es = n - mark[len(mark) - 1]
	for i in range(len(zinb)):
		val = (zinb[i] - k) // (k + 1)
		if val > 0:
			ans += val
	b1 = bs // (k + 1)
	e1 = es // (k + 1)
	if b1 > 0:
		ans += b1
	if e1 > 0:
		ans += e1
	print(ans)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ind = list()
	for j in range(len(s)):
		if s[j] == '1':
			ind.append(j)
	cnt = 0
	curr = 0
	if len(ind) == 0:
		cnt = 1
		curr = curr + k + 1
		while curr < len(s):
			cnt += 1
			curr = curr + k + 1
		print(cnt)
		continue
	while curr + k < ind[0]:
		cnt += 1
		curr = curr + k + 1
	curr = ind[0] + k + 1
	for j in range(1, len(ind)):
		while curr + k < ind[j]:
			cnt += 1
			curr = curr + k + 1
		curr = ind[j] + k + 1
	curr = ind[len(ind) - 1] + k + 1
	while curr < len(s):
		cnt += 1
		curr = curr + k + 1
	print(cnt)


t = int(input())
while t != 0:
	t -= 1
	(n, k) = [int(x) for x in input().split()]
	s = list(input())
	ind = []
	for i in range(len(s)):
		if s[i] == '1':
			ind.append(i)
	ctr = 0
	if len(ind) == 0:
		if n % (k + 1) != 0:
			print(n // (k + 1) + 1)
		else:
			print(n // (k + 1))
		continue
	if len(ind) > 0:
		if ind[0] > 0:
			ctr += ind[0] // (k + 1)
		if n - 1 - ind[-1] > 0:
			ctr += (n - 1 - ind[-1]) // (k + 1)
	if len(ind) > 1:
		for i in range(1, len(ind)):
			x = ind[i] - ind[i - 1] - 1
			if x - k > 0:
				ctr += (x - k) // (k + 1)
	print(ctr)


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


def solve(n, k, s):
	ones = [i for (i, v) in enumerate(s) if v == '1']
	no = len(ones)
	if no == 0:
		return n // (k + 1) + bool(n % (k + 1))
	left = 0
	res = 0
	ix = 0
	while left < n:
		if left < ones[ix] - k:
			res += 1
			left += k + 1
		else:
			left = ones[ix] + k + 1
			ix += 1
			if ix >= no:
				if left < n:
					return (n - left) // (k + 1) + bool((n - left) % (k + 1)) + res
	return res
t = int(input())
for i in range(t):
	[n, k] = list(map(int, input().split(' ')))
	s = input()
	print(solve(n, k, s))


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(N, K) = [int(x) for x in input().split()]
		S = input().strip()
		ans = 0
		distance = float('inf')
		kari = False
		for i in range(N):
			if S[i] == '0':
				if distance >= K:
					ans += 1
					kari = True
					distance = 0
				else:
					distance += 1
			else:
				if distance < K and kari:
					ans -= 1
				kari = False
				distance = 0
		print(ans)
main()


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	s = input()
	m = 0
	dd = 0
	flag = 0
	for j in range(0, n):
		if s[j] == '0':
			m += 1
		else:
			if flag == 0:
				dd = dd + m // (k + 1)
			else:
				dd = dd + max((m - k) // (k + 1), 0)
			m = 0
			flag = 1
	if flag == 0:
		dd = dd + (m + k) // (k + 1)
	else:
		dd = dd + max(0, m // (k + 1))
	print(dd)


import sys
from re import *
from math import ceil as ce
cont = sys.stdin.readlines()
cont = [i.strip('\n').split() for i in cont]
numTests = int(cont.pop(0)[0])
nc = []
for i in range(numTests):
	nc.append(cont[:2])
	cont = cont[2:]
for table in nc:
	(n, k) = table.pop(0)
	(n, k) = (int(n), int(k))
	table = table[0][0]
	count = 0
	table = '2' + table + '2'
	ind1 = [ind for (ind, i) in enumerate(table) if i == '1' or i == '2']
	empty = []
	ind = 0
	for ind in range(len(ind1)):
		if ind == len(ind1) - 1:
			break
		empty.append(table[ind1[ind]:ind1[ind + 1] + 1])
	empty = [i for i in empty if i != '11' and i != '12' and (i != '21') and (i != '22')]
	for i in empty:
		tlen = len(i)
		if i[0] == '1':
			tlen += -1 - k
		if i[0] == '2':
			tlen -= 1
		if i[-1] == '1':
			tlen += -1 - k
		if i[-1] == '2':
			tlen -= 1
		if tlen > 0:
			count += int(ce(tlen / (k + 1)))
	print(count)


for _ in [0] * int(input()):
	k = int(input().split()[1])
	s = input()
	distances = [len(s) for s in s.split('1')]
	count = 0
	if len(distances) == 1:
		print(1 + (len(s) - 1) // (k + 1))
		continue
	if distances[0] > k:
		count += distances[0] // (k + 1)
	for i in range(1, len(distances) - 1):
		if distances[i] >= 2 * k + 1:
			count += (distances[i] - k) // (k + 1)
	if distances[-1] > k:
		count += distances[-1] // (k + 1)
	print(count)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ps = [0] * n
	ps[0] = int(s[0])
	for i in range(1, n):
		ps[i] = ps[i - 1] + (1 if s[i] == '1' else 0)
	c = 0
	i = 0
	while i < n:
		if s[i] == '1':
			i += k
		elif s[i] == '0':
			if i + k < n and ps[i] == ps[i + k]:
				c += 1
				i += k
			elif i == n - 1:
				c += 1
				break
		i += 1
	print(c)


import sys
import heapq
import random
import collections

def solve(k, lst):
	console('----- solving ------')
	arr = ('1' + '0' * k + lst + '0' * k + '1').split('1')
	res = 0
	for ar in arr:
		if len(ar) > k:
			res += (len(ar) - k) // (k + 1)
	return res

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	(_, k) = list(map(int, input().split()))
	lst = input()
	res = solve(k, lst)
	print(res)


def ans(n, k, a):
	index = 0
	x = 0
	while index < len(a):
		if a[index] == '0':
			one_ind = None
			for j in range(index - k, index + k + 1):
				if j > 0 and j < len(a) and (a[j] == '1'):
					one_ind = j
			if one_ind == None:
				x += 1
				index += k + 1
			else:
				index = one_ind + k + 1
		else:
			one_ind = None
			for j in range(index - k, index + k + 1):
				if j < len(a) and a[j] == '1':
					one_ind = j
			if one_ind == None:
				index += k + 1
			else:
				index = one_ind + k + 1
	return x
m = int(input())
for i in range(m):
	b = input().split()
	n = int(b[0])
	k = int(b[1])
	arr = input()
	print(ans(n, k, arr))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = list(input())
	ans = 0
	i = 0
	while i < a:
		if c[i] == '0':
			ss = i
			while i < a and i < ss + b:
				if c[i] == '1':
					break
				else:
					i += 1
			if i == a or (i == ss + b and c[i] != '1'):
				i += 1
				c[ss] = '1'
				ans += 1
		else:
			i += b + 1
	print(ans)


t = int(input())
for qwe in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input()))
	listt = []
	flag = False
	try:
		ind = a.index(1)
		flag = False
	except:
		flag = True
	if flag:
		listt.append(n)
	else:
		ind = a.index(1)
		temp = ind - k
		if temp > 0:
			listt.append(temp)
		for i in range(ind + 1, n):
			if a[i] == 1:
				temp = i - ind - 1 - k * 2
				if temp > 0:
					listt.append(temp)
				ind = i
		temp = n - ind - 1 - k
		if temp > 0:
			listt.append(temp)
	ans = 0
	for i in range(len(listt)):
		ans += (listt[i] + k) // (k + 1)
	print(ans)


for i in range(int(input())):
	a = list(map(int, input().split()))
	b = input()
	z = a[1]
	s = 0
	for i2 in b:
		z += 1
		if i2 == '1':
			z = 0
		elif z == a[1] * 2 + 1:
			s += 1
			z = a[1]
	if z >= a[1] + 1:
		s += 1
	print(s)


t = int(input())
for ex in range(t):
	(n, k) = [int(i) for i in input().split()]
	s = input()
	free = [1 for i in range(n)]
	for i in range(n):
		if s[i] == '1':
			if i - k >= 0:
				j = i - k
			else:
				j = 0
			while j <= i + k and j < n:
				free[j] = 0
				j += 1
	series = list()
	in_a_s = False
	series_far_to_right = False
	series_far_to_left = False
	for i in range(n):
		if free[i] == 1:
			if in_a_s:
				series[len(series) - 1] += 1
			else:
				in_a_s = True
				series.append(1)
		else:
			in_a_s = False
	ans = int(0)
	for i in range(len(series)):
		num = 1
		while series[i] // (num + (num - 1) * k) > 0:
			num += 1
		num -= 1
		ans += num
	if free.count(1) > 0 and ans == 0:
		print('1')
	else:
		print(ans)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if all((state == '0' for state in s)):
		print(math.ceil(max(n, k + 1) / (k + 1)))
	else:
		count = 0
		groups = s.split('1')
		for (i, group) in enumerate(groups):
			if i == 0 or i == len(groups) - 1:
				count += len(group) // (k + 1)
			else:
				count += (len(group) - k) // (k + 1)
		print(count)


testcases = int(input())
import math
for testcase in range(testcases):
	temparr = input()
	temparr = temparr.split()
	n = int(temparr[0])
	k = int(temparr[1])
	strs = input()
	total = 0
	oneindex = []
	strslen = len(strs)
	oneindex.append(int(-1))
	for (j, i) in enumerate(strs):
		if i == '1':
			oneindex.append(j)
	oneindex.append(strslen)
	if len(oneindex) == 2:
		print(math.ceil(strslen / (k + 1)))
		continue
	oneindexlen = len(oneindex)
	total = 0
	for i in range(1, oneindexlen):
		firstindex = oneindex[i - 1]
		secondindex = oneindex[i]
		if firstindex == -1 and secondindex == 0:
			continue
		if firstindex == -1:
			numberofzeros = secondindex
			numberofzeros -= k
			if numberofzeros <= 0:
				continue
			else:
				total += math.ceil(numberofzeros / (k + 1))
			continue
		elif secondindex == oneindex[-1]:
			differenceindex = secondindex - firstindex - 1
			differenceindex -= k
			if differenceindex <= 0:
				continue
			else:
				total += math.ceil(differenceindex / (k + 1))
			continue
		else:
			differenceindex = secondindex - firstindex - 1
			differenceindex -= k
			differenceindex -= k
			if differenceindex <= 0:
				continue
			else:
				total += math.ceil(differenceindex / (k + 1))
			continue
	print(total)


n = int(input())
for _ in range(n):
	(t, k) = map(int, input().split())
	l = input()
	count = 0
	i = 0
	d = 0
	while i < t:
		flag = True
		if l[i] == '0':
			for j in range(i + 1, i + k + 1):
				if j < t:
					if l[j] == '1':
						flag = False
						d = j
			if flag:
				count += 1
		if flag == False:
			i = d + k + 1
		else:
			i = i + k + 1
	print(count)


import math
for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	a = []
	f = 0
	for i in range(len(s)):
		if s[i] == '1':
			a.append(i)
			f = 1
	su = 0
	if f == 0:
		if n >= k + 1:
			su = math.ceil(n / (k + 1))
		else:
			su = 1
	elif len(a) == 1:
		if a[0] > 0:
			y = a[0]
			su = y // (k + 1)
		if a[0] < n - 1:
			y = n - 1 - a[0]
			su += y // (k + 1)
	else:
		for i in range(len(a)):
			if i == 0:
				if a[i] == 0:
					y = a[i + 1] - a[i] - 1
					if y >= 2 * k + 1:
						y -= 2 * k
						su += math.ceil(y / (k + 1))
				else:
					y = a[i]
					if y >= k + 1:
						y -= k
						su += math.ceil(y / (k + 1))
					y = a[i + 1] - a[i] - 1
					if y >= 2 * k + 1:
						y -= 2 * k
						su += math.ceil(y / (k + 1))
			elif i == len(a) - 1:
				if a[i] == n - 1:
					break
				else:
					y = n - 1 - a[i]
					if y >= k + 1:
						y -= k
						su += math.ceil(y / (k + 1))
			else:
				y = a[i + 1] - a[i] - 1
				if y >= 2 * k + 1:
					y -= 2 * k
					su += math.ceil(y / (k + 1))
	print(su)


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	s = input()
	answer = 0
	local = k
	for i in range(n):
		if s[i] == '0':
			local += 1
		elif s[i] == '1':
			local = 0
		if local == 2 * k + 1:
			local = k
			answer += 1
	if local > k:
		answer += 1
	print(answer)


def solve():
	(n, k) = map(int, input().split())
	s = input()
	a = []
	c = 0
	for i in range(n):
		if i - k - 1 >= 0 and s[i - k - 1] == '1':
			c -= 1
		if s[i] == '1':
			c += 1
		elif c == 0:
			a.append(i)
	b = []
	c = 0
	for i in range(n - 1, -1, -1):
		if i + k + 1 < n and s[i + k + 1] == '1':
			c -= 1
		if s[i] == '1':
			c += 1
		elif c == 0:
			b.append(i)
	a.sort()
	b.sort()
	t = []
	(la, lb) = (len(a), len(b))
	p = 0
	for i in range(la):
		while p < lb and b[p] < a[i]:
			p += 1
		if p < lb and b[p] == a[i]:
			t.append(a[i])
	p = -100000000
	ans = 0
	for x in t:
		if x - p >= k + 1:
			ans += 1
			p = x
	print(ans)
for _ in range(int(input())):
	solve()


from math import ceil
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = input()
	temp = []
	for i in range(n):
		if l[i] == '1':
			temp.append(i)
	if len(temp) == 0:
		p = ceil(n / (k + 1))
		if p == 0:
			print(1)
		else:
			print(p)
	else:
		ans = 0
		a = temp[0]
		ans += a // (k + 1)
		for i in range(len(temp) - 1):
			a = temp[i]
			b = temp[i + 1]
			ans += (b - a) // (k + 1) - 1
		a = n - temp[len(temp) - 1] - 1
		ans += a // (k + 1)
		print(ans)


from math import ceil
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	gaps = []
	pgs = 0
	for i in a:
		if i == '1':
			if pgs - k > 0:
				gaps.append(pgs - k)
			pgs = -k
		else:
			pgs += 1
	if a[-1] != '1':
		if pgs > 0:
			gaps.append(pgs)
	if gaps:
		t = 0
		for i in gaps:
			t += ceil(i / (1 + k))
		print(t)
	else:
		print(0)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if s.count('1') == 0:
		ans = n // (k + 1)
		if n % (k + 1) > 0:
			ans += 1
	else:
		pre = -1
		ans = 0
		for i in range(n):
			if s[i] == '1':
				if pre == -1:
					if i - k > 0:
						ans += (i - k) // (k + 1)
						if (i - k) % (k + 1) > 0:
							ans += 1
				elif i - pre - 1 > 0:
					d = i - pre - 1 - k
					if d > 0:
						ans += d // (k + 1)
				pre = i
		if pre != n - 1:
			d = n - 1 - pre - k
			if d > 0:
				ans += d // (k + 1)
				if d % (k + 1) > 0:
					ans += 1
	print(ans)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	i = 0
	count = 0
	ans = 0
	x = 0
	fg = 0
	while i < n:
		if s[i] == '0':
			if fg == 1:
				count += 1
				if count > 2 * k:
					ans += 1
					i -= k
					count = 0
			else:
				count += 1
				x += 1
				if count > k:
					ans += 1
					count = 0
		elif s[i] == '1':
			fg = 1
			count = 0
		i += 1
	if n == x:
		print(math.ceil(n / (k + 1)))
	elif s[-1] == '0' and count > k:
		print(ans + 1)
	else:
		print(ans)


import math

def add_people_func(empty_space, k):
	return math.ceil(max(empty_space, 0) / (k + 1))

def task_C():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		array = input()
		i = 0
		empty_space = 0
		add_people = 0
		begins = array[0] == '0'
		while i < n:
			if array[i] == '0':
				empty_space += 1
			else:
				if begins:
					add_people += add_people_func(empty_space - k, k)
					begins = False
				else:
					add_people += add_people_func(empty_space - k * 2, k)
				empty_space = 0
			i += 1
		if empty_space != 0:
			if begins:
				add_people += add_people_func(empty_space, k)
			else:
				add_people += add_people_func(empty_space - k, k)
		print(add_people)

def main():
	task_C()
main()


def main(n, k, s):
	used = [i for (i, x) in enumerate(s) if x == '1']
	used.append(n + k)
	res = 0
	first = 0
	for u in used:
		res += (u - first) // (k + 1)
		first = u + k + 1
	return res
t = int(input())
for _ in range(t):
	print(main(*map(int, input().split()), input()))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ls = list(map(int, input()))
	gaps = []
	st = -1
	for i in range(n):
		if ls[i]:
			st = i
			break
	if st != -1:
		cnt = 0
		g1 = st
		if g1 - k > 0:
			g1 -= k
			cnt += (g1 - 1) // (k + 1) + 1
		for i in range(st + 1, n):
			if ls[i]:
				gaps.append(i - st - 1)
				st = i
		for i in gaps:
			if i - 2 * k > 0:
				g = i - 2 * k
				cnt += (g - 1) // (k + 1) + 1
		g2 = n - (st + 1)
		if g2 - k > 0:
			g2 -= k
			cnt += (g2 - 1) // (k + 1) + 1
	else:
		cnt = (n - 1) // (k + 1) + 1
	print(cnt)


t = int(input())
while t:
	(n, k) = list(map(int, input().split()))
	arr = input()
	if int(arr) == 0 and n <= k:
		print(1)
	elif int(arr) == 0:
		if n % (k + 1):
			print(n // (k + 1) + 1)
		else:
			print(n // (k + 1))
	else:
		ans = 0
		p1 = 0
		while p1 < n:
			if int(arr[p1]) == 0:
				p2 = p1
				while p2 < n and int(arr[p2]) == 0:
					p2 += 1
				if p1 == 0 or p2 == n:
					ans += (p2 - p1) // (k + 1)
				elif p2 - p1 >= 2 * k:
					if (p2 - p1 - 2 * k) % (k + 1):
						ans += (p2 - p1 - 2 * k) // (k + 1) + 1
					else:
						ans += (p2 - p1 - 2 * k) // (k + 1)
				p1 = p2
			else:
				p1 += 1
		print(ans)
	t -= 1


list_ans = []
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = '1' + '0' * k + input() + '0' * k + '1'
	list1 = s.split('1')
	ans = 0
	for x in list1:
		ans += max((len(x) + 1) // (k + 1) - 1, 0)
	list_ans.append(ans)
for item in list_ans:
	print(item)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d

def divup(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1
t = int(input())
for q in range(t):
	(n, k) = inputnums()
	s = inputstring()
	ans = 0
	i = 0
	if s.count('0') == n:
		print(divup(n, k + 1))
		continue
	while i < n:
		skip = 1
		if s[i] == '0':
			j = 0
			while i + j < n and s[i + j] == '0':
				j += 1
			skip = j
			if i == 0 or i + j == n:
				j -= k
			else:
				j -= 2 * k
			if j > 0:
				ans += divup(j, k + 1)
		i += skip
	print(ans)


def f(n, k, a):
	i = 0
	ctx = 0
	i = 0
	while i < n:
		j = i
		while j <= i + k and j < n:
			if a[j] == '1':
				j = j + k + 1
				break
			else:
				j += 1
		else:
			ctx += 1
			i += k + 1
		i = j
	return ctx
for tt in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	revA = a[::-1]
	a1 = f(n, k, a)
	a2 = f(n, k, revA)
	ctx = max(a1, a2)
	print(ctx)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(input())
	x = []
	c = 0
	for i in range(n):
		if l[i] == '1':
			x.append(i + 1)
			c += 1
	p = 0
	for i in range(c):
		if i == 0:
			a = x[i] - k - 1
			b = a + k
			p += b // (k + 1)
		else:
			a = x[i] - x[i - 1] - 2 * k - 1
			b = a + k
			p += b // (k + 1)
	if c != 0:
		a = n - x[c - 1] - k
		b = a + k
		p += b // (k + 1)
	else:
		a = n
		b = a + k
		p += b // (k + 1)
	print(p)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	j = 0
	flag = 1
	for i in range(len(s)):
		if s[i] == '0':
			j += 1
			if j == k + 1:
				ans += 1
				j = 0
			elif i == n - 1 and j > 0:
				ans += 1
		else:
			j = -k
	print(ans)


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange
sys.setrecursionlimit(10 ** 2)

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 998244353

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k))))
from collections import deque, defaultdict
import heapq
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def dfs(g, timeIn, timeOut, depths, parents):
	cnt = 0
	stack = [[1, 0, 0, 0]]
	while stack:
		(v, neig_i, parent, depth) = stack[-1]
		parents[v] = parent
		depths[v] = depth
		if neig_i == 0:
			timeIn[v] = cnt
			cnt += 1
		while neig_i < len(g[v]):
			u = g[v][neig_i]
			if u == parent:
				neig_i += 1
				continue
			stack[-1][1] = neig_i + 1
			stack.append([u, 0, v, depth + 1])
			break
		if neig_i == len(g[v]):
			stack.pop()
			timeOut[v] = cnt
			cnt += 1

def isAncestor(u: int, v: int, timeIn: list, timeOut: list) -> str:
	return timeIn[u] <= timeIn[v] and timeOut[v] <= timeOut[u]
cnt = 0

@bootstrap
def dfs(v, adj, timeIn, timeOut, depths, parents, parent=0, depth=0):
	global cnt
	parents[v] = parent
	depths[v] = depth
	timeIn[v] = cnt
	cnt += 1
	for u in adj[v]:
		if u == parent:
			continue
		yield dfs(u, adj, timeIn, timeOut, depths, parents, v, depth + 1)
	timeOut[v] = cnt
	cnt += 1
	yield

def solution(s, n, k):
	a = []
	sol = 0
	diff = 0
	seen_one = False
	for i in range(n):
		x = s[i]
		if x == '0':
			diff += 1
			continue
		if not seen_one:
			seen_one = True
			sol += diff // (k + 1)
		else:
			sol += max(0, (diff - k) // (k + 1))
		diff = 0
	return sol + (diff // (k + 1) if seen_one else (diff - 1) // (k + 1) + 1)

def main():
	T = 1
	T = ri()
	for i in range(T):
		(n, k) = ria()
		s = rs()
		x = solution(s, n, k)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
import math
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()
rli = lambda : map(int, stdin.readline().split())
rlf = lambda : map(float, stdin.readline().split())
(INF, NINF) = (float('inf'), float('-inf'))

def grp(A):
	ans = []
	(curr, currlen) = (None, 0)
	typ = 'E'
	for (i, a) in enumerate(A):
		if a != curr:
			if curr is not None and curr == 0:
				ans.append((currlen, typ))
			typ = 'N' if curr is not None else 'E'
			(curr, currlen) = (a, 1)
		else:
			currlen += 1
	if currlen > 0 and curr == 0:
		ans.append((currlen, 'DE' if typ == 'E' else 'E'))
	return ans

def cnt(grplen, grptype, k):
	if grptype == 'N':
		return grplen // (k + 1) - (1 if grplen % 2 == 0 else 0)
	elif grptype == 'E':
		return grplen // (k + 1)
	else:
		(x, rem) = divmod(grplen, k + 1)
		return x + (1 if rem > 0 else 0)

def cnt2(grplen, grptype, k):
	if grptype == 'N':
		grplen -= 2 * k
	elif grptype == 'E':
		grplen -= k
	(x, rem) = divmod(grplen, k + 1)
	return x + (1 if rem > 0 else 0)

def main():
	T = int(rl())
	for _ in range(T):
		(n, k) = rli()
		A = list(map(int, rll()[0]))
		ans = 0
		for (glen, gtype) in grp(A):
			ans += cnt2(glen, gtype, k)
		print(ans)
	stdout.close()
main()


for _ in range(int(input())):
	(x, k) = map(int, input().split())
	a = input()
	valid_num = 0
	count_2 = k
	count = k
	for i in range(len(a)):
		if a[i] == '1':
			count = 0
			if count_2 > 0:
				valid_num -= 1
			if valid_num < 0:
				valid_num = 0
			count_2 = k
		elif a[i] == '0':
			count += 1
			count_2 -= 1
			if count > k:
				count = 0
				valid_num += 1
				count_2 = k
	print(valid_num)


from math import *
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	c = 0
	l = []
	for i in range(n):
		if s[i] == '1':
			l.append(i)
	if len(l) == 0:
		c = c + 1
		n = n - 1
		ans = n // (k + 1)
		c = c + ans
	else:
		for i in range(len(l) - 1):
			m = l[i + 1] - l[i] - 1 - k
			m = max(0, m)
			ans = m // (k + 1)
			c = c + ans
		m = l[0] // (k + 1)
		c = c + m
		l.reverse()
		ans = (n - l[0] - 1) // (k + 1)
		c = c + ans
	print(c)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = list(input())
	a = []
	total = 0
	for i in range(n):
		if s[i] == '1':
			a.append(i)
	if len(a) == 0:
		if n % (1 + k) == 0:
			total = n // (1 + k)
		else:
			total = n // (1 + k) + 1
		if total == 0:
			total += 1
	elif len(a) > 0:
		total += a[0] // (1 + k)
		total += (n - a[-1] - 1) // (1 + k)
		for i in range(len(a) - 1):
			nn = a[i + 1] - a[i]
			total += (nn - k - 1) // (k + 1)
	print(total)


T = int(input())
for t in range(T):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	s = input()
	s = '0' * k + s + '0' * k
	ans = 0
	sm = 0
	for (i, a) in enumerate(s):
		if a == '1':
			tmp = (sm - k) // (k + 1)
			if tmp > 0:
				ans += tmp
			sm = 0
		else:
			sm += 1
	tmp = (sm - k) // (k + 1)
	if tmp > 0:
		ans += tmp
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	s = input()
	setter = 0
	answer = 0
	while setter < n:
		if s[setter] == '1':
			setter += k
		else:
			for j in range(setter + 1, setter + k + 1):
				if j < n and s[j] == '1':
					setter = j + k
					break
				if j == setter + k:
					answer += 1
					setter += k
		setter += 1
	print(answer)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	d = 0
	ans = 0
	nf = True
	for i in range(len(s)):
		if s[i] == '0':
			d += 1
			if d > k or nf:
				ans += 1
				d = 0
				nf = False
		else:
			nf = False
			if d < k and i != 0:
				ans -= 1
			d = 0
	if d > k:
		ans += 1
	print(ans)


from math import ceil
T = int(input())
D = []
for i in range(0, T):
	(n, k) = [int(x) for x in input().split(' ')]
	A = [int(x) for x in input()]
	B = []
	for j in range(0, len(A)):
		if A[j] == 1:
			B.append(j)
	if len(B) == 0:
		D.append(ceil(n / (k + 1)))
	else:
		X = 0
		for j in range(0, len(B) - 1):
			X += (B[j + 1] - B[j]) // (k + 1) - 1
		X += (n - 1 - B[len(B) - 1]) // (k + 1)
		X += B[0] // (k + 1)
		D.append(X)
for i in D:
	print(i)


cases = int(input())
for case in range(cases):
	(length, distance) = map(int, input().split())
	nums = list(map(int, list(input())))
	for index in range(length):
		if nums[index] == 1:
			if index - distance >= 0:
				for temp in range(index - 1, index - distance - 1, -1):
					if nums[temp] == 0:
						nums[temp] = -1
			else:
				for temp in range(index - 1, -1, -1):
					if nums[temp] == 0:
						nums[temp] = -1
			if index + distance <= length - 1:
				for temp in range(index + 1, index + distance + 1):
					if nums[temp] == 0:
						nums[temp] = -1
			else:
				for temp in range(index + 1, length):
					if nums[temp] == 0:
						nums[temp] = -1
	temp_index = 0
	count = 0
	while temp_index < length:
		if nums[temp_index] == 0:
			count += 1
			temp_index += distance + 1
		else:
			temp_index += 1
	print(count)


from collections import deque
t = int(input())
c = []
for i in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	s = input()
	q = deque()
	for i in range(n):
		if s[i] == '1':
			q.append(i)
	total = 0
	if len(q) == 0:
		total += n // (k + 1)
		if n % (k + 1) != 0:
			total += 1
	else:
		p = len(q)
		prev = q.popleft()
		for i in range(p):
			if i == 0:
				g = prev - k
			else:
				next = q.popleft()
				g = next - prev - 1 - 2 * k
				prev = next
			if g > 0:
				total += g // (k + 1)
				if g % (k + 1) != 0:
					total += 1
		g = n - prev - 1 - k
		if g > 0:
			total += g // (k + 1)
			if g % (k + 1) != 0:
				total += 1
	c.append(total)
for j in c:
	print(j)


def solve(s: str, k: int) -> int:
	sx = ''.join(['1', '0' * k, s, '0' * k, '1'])
	a = [i for i in range(len(sx)) if sx[i] == '1']
	return sum([(a[i] - a[i - 1]) // (k + 1) - 1 for i in range(1, len(a))])
tc = int(input())
while tc > 0:
	(n, k) = map(int, input().split())
	print(solve(input(), k))
	tc -= 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	arr = list(s)
	if n == 1:
		if arr[0] == '0':
			print(1)
			continue
		else:
			print(0)
			continue
	check = 0
	res = 0
	j = 0
	start = 0
	while j < n:
		if arr[j] == '1':
			check = 0
			start = 1
		else:
			check += 1
		if start == 0 and check == k + 1:
			res += 1
			check = k
			start = 1
		if check == 2 * k + 1:
			res += 1
			check = k
		j += 1
	if n <= k and check == k:
		print(1)
		continue
	if check >= k + 1:
		res += 1
	print(res)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().strip()))
	l = [-k - 1]
	for i in range(n):
		if arr[i] == 1:
			l += [i]
	l += [n + k]
	ans = 0
	for i in range(1, len(l)):
		dif = l[i] - l[i - 1] - 1 - (2 * k + 1)
		if dif >= 0:
			ans += 1 + dif // (k + 1)
	print(ans)


import math
t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	s = input()
	pos = []
	for i in range(n):
		if s[i] == '1':
			pos.append(i)
	m = len(pos)
	ans = 0
	if m == 0:
		print(math.ceil(n / (k + 1)))
	else:
		if pos[0] - k > 0:
			ans += math.ceil((pos[0] - k) / (k + 1))
		for i in range(1, m):
			ans += math.ceil((pos[i] - pos[i - 1] - 1 - 2 * k) / (k + 1))
		if n - pos[-1] - k - 1 > 0:
			ans += math.ceil((n - pos[-1] - k - 1) / (k + 1))
		print(ans)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return list(map(int, input().split()))

def solve(nums):
	hash_map = {}

	def helper(i):
		if i >= len(nums):
			return 0
		_max = 0
		if i in hash_map:
			return hash_map[i]
		if nums[i] == '0':
			_max = max(_max, helper(i + 1))
			found = False
			for _i in nums[i + 1:i + k + 1]:
				if _i == '1':
					found = True
					break
			if not found:
				_max = max(_max, 1 + helper(i + k + 1))
		else:
			_max = helper(i + k + 1)
		hash_map[i] = _max
		return _max
	return helper(0)

def solve2():
	index_arr = []
	start = None
	for (i, num) in enumerate(arr):
		if num == '1':
			if start is not None:
				index_arr.append([start, i - 1])
				start = None
			continue
		if start is None:
			start = i
	if start is not None:
		index_arr.append([start, len(arr) - 1])
	if len(index_arr) == 1 and index_arr[0][0] == 0 and (index_arr[0][1] == len(arr) - 1):
		return math.ceil(len(arr) / (k + 1))
	count = 0
	for _i in index_arr:
		if _i[1] - k < _i[0]:
			continue
		if _i[0] == 0:
			start = _i[0]
			end = _i[1] - k
			count += math.ceil((end - start + 1) / (k + 1))
		elif _i[1] == len(arr) - 1:
			start = _i[0] + k
			end = _i[1]
			count += math.ceil((end - start + 1) / (k + 1))
		else:
			start = _i[0] + k
			end = _i[1] - k
			count += math.ceil((end - start + 1) / (k + 1))
	return count
tests = inp()
for t in range(tests):
	nk = inlt()
	n = nk[0]
	k = nk[1]
	arr = insr()
	print(solve2())


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(input())
	i = 0
	while i < n:
		if l[i] == '1':
			for j in range(k):
				i += 1
				if i >= n:
					break
				else:
					l[i] = 'h'
		i += 1
	i = n - 1
	while i >= 0:
		if l[i] == '1':
			for j in range(k):
				i -= 1
				if i < 0:
					break
				else:
					l[i] = 'h'
		i -= 1
	cnt = 0
	i = 0
	while i < n:
		if l[i] == '0':
			cnt += 1
			i = i + k
		i += 1
	print(cnt)


a = int(input())
for _ in range(a):
	(n, k) = map(int, input().split())
	s = input()
	a = 0
	z = -100000000
	lis = [int(i) for i in s]
	for i in range(len(lis)):
		if lis[i] == 1:
			if i <= k + z:
				a -= 1
			z = i
			continue
		if i > k + z:
			a += 1
			z = i
	print(a)


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	for _ in range(II()):
		(n, k) = MI()
		s = '0' * k + SI() + '0' * k + '1'
		cnt = 0
		ans = 0
		for c in s:
			if c == '0':
				cnt += 1
			else:
				if cnt - k > 0:
					ans += (cnt - k) // (k + 1)
				cnt = 0
		print(ans)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	c = 0
	if '1' not in s:
		ans = 1
		for i in range(k + 1, n, k + 1):
			ans += 1
		print(ans)
	else:
		f = s.find('1')
		ans = 0
		for i in range(f - 1, -1, -1):
			c += 1
			if c > k:
				ans += 1
				c = 0
		c = 0
		for i in range(f + 1, n):
			c += 1
			if s[i] == '1':
				c = 0
			elif c > k and i + k + 1 <= n:
				sb = s[i + 1:i + k + 1]
				if '1' not in sb:
					ans += 1
					c = 0
			elif c > k and i + 1 < n:
				sb = s[i + 1:n]
				if '1' not in sb:
					ans += 1
					c = 0
			elif c > k:
				ans += 1
				c = 0
		print(ans)


from math import *

def r1(t):
	return t(input())

def r2(t):
	return [t(i) for i in input().split()]

def r3(t):
	return [t(i) for i in input()]
for _ in range(r1(int)):
	(n, k) = r2(int)
	s = input()
	s = '0' * k + s + '0' * k + '1'
	cl = 0
	ans = 0
	for i in range(len(s)):
		if s[i] == '1':
			ans += max(0, (cl - k) // (k + 1))
			cl = 0
		else:
			cl += 1
	print(ans)


for mda in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	cur = 0
	ans = 0
	left = False
	for i in range(n):
		if a[i] == '0':
			if i == 0:
				left = True
			cur += 1
		else:
			if left == True:
				cur -= k
			else:
				cur -= 2 * k
			if cur > 0 and cur % (k + 1) == 0:
				ans += cur // (k + 1)
			elif cur > 0:
				ans += cur // (k + 1) + 1
			cur = 0
			left = False
	if left == True:
		if n % (k + 1) == 0:
			print(n // (k + 1))
		else:
			print(n // (k + 1) + 1)
	else:
		cur -= k
		if cur > 0 and cur % (k + 1) == 0:
			ans += cur // (k + 1)
		elif cur > 0:
			ans += cur // (k + 1) + 1
		print(ans)


def solve(s, k):
	s = '1' + '0' * k + s + '0' * k + '1'
	blocks = s.split('1')
	total = 0
	for block in blocks:
		size = len(block)
		if size == 0:
			continue
		else:
			total += max(0, (size - k) // (k + 1))
	return total
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

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)))
main()


import sys
import heapq

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, sys.stdin.readline().split())
		s = sys.stdin.readline().strip()
		if len(s) == 1:
			if s[0] == '0':
				print(1)
			else:
				print(0)
			continue
		if n == k:
			if '1' in s:
				print(0)
			else:
				print(1)
			continue
		onePos = []
		nums = []
		for i in range(n):
			if s[i] == '1':
				onePos.append(i)
			nums.append(int(s[i]))
		if not onePos:
			ans = n // (k + 1)
			if n % (k + 1):
				ans += 1
			print(ans)
			continue
		invalid = []
		for pos in onePos:
			if not invalid:
				invalid.append([max(0, pos - k), min(n - 1, pos + k)])
				continue
			if pos - k <= invalid[-1][1]:
				invalid[-1][1] = min(n - 1, pos + k)
			else:
				invalid.append([max(0, pos - k), min(n - 1, pos + k)])
		ans = 0
		pos = 0
		for i in invalid:
			ans += (i[0] - pos) // (k + 1)
			if (i[0] - pos) % (k + 1):
				ans += 1
			pos = i[1] + 1
		ans += (n - pos) // (k + 1)
		if (n - pos) % (k + 1):
			ans += 1
		print(ans)
	return
main()


from sys import stdout
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	prev = -1
	ans = 0
	flag = False
	for i in range(n):
		if s[i] == '0' and prev == -1:
			ans += 1
			prev = i
			flag = True
			continue
		if s[i] == '0' and prev > -1:
			if i - prev == k + 1:
				ans += 1
				prev = i
				flag = True
			continue
		if s[i] == '1' and prev == -1:
			prev = i
			flag = False
			continue
		if s[i] == '1' and prev > -1:
			if i - prev != k + 1 and flag == True:
				ans -= 1
				prev = i
			else:
				prev = i
	stdout.write(str(ans) + '\n')


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	l = [-1 for i in range(n)]
	r = [-1 for i in range(n)]
	prev = -1
	for i in range(n):
		l[i] = max(l[i], prev)
		if s[i] == '1':
			prev = i
	prev = -1
	for i in range(n - 1, -1, -1):
		r[i] = max(r[i], prev)
		if s[i] == '1':
			prev = i
	ans = 0
	f = 0
	for i in range(n):
		if s[i] != '1' and i != 0 and (f == 1):
			l[i] = l[i - 1]
		if (l[i] == -1 or i - l[i] > k) and (r[i] == -1 or r[i] - i > k) and (s[i] != '1'):
			ans += 1
			l[i] = i
			f = 1
		if s[i] == '1':
			f = 0
	print(ans)


from math import ceil
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(input())
	for i in range(n):
		arr[i] = int(arr[i])
	poss = -1
	posl = -1
	for i in range(n):
		if arr[i] == 1:
			if poss == -1:
				poss = i
			posl = i
	if poss == posl and poss == -1:
		print(ceil(n / (k + 1)))
	else:
		ans = 0
		ans += ceil(max(poss - k, 0) / (k + 1))
		ans += ceil(max(n - posl - 1 - k, 0) / (k + 1))
		start = poss + 1
		end = posl
		for i in range(poss + 1, posl):
			if arr[i] == 1:
				end = i
				ans += ceil(max(end - start - 2 * k, 0) / (k + 1))
				start = i + 1
		ans += ceil(max(posl - start - 2 * k, 0) / (k + 1))
		print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input().strip()
	if n == 1:
		if s[0] != '1':
			print(1)
		else:
			print(0)
	elif n <= k and s.count('1') != 0:
		print(0)
	else:
		ones = []
		for i in range(0, n):
			if s[i] == '1':
				ones.append(i)
		ans = 0
		if len(ones) != 0:
			for i in range(0, len(ones) - 1):
				if ones[i + 1] - ones[i] - 1 >= 2 * k + 1:
					b = ones[i + 1] - ones[i] - 1 - k
					ans += b // (k + 1)
			if ones[0] != 0:
				b = ones[0]
				if b >= k + 1:
					ans += b // (k + 1)
			g = len(ones)
			if ones[g - 1] != n - 1:
				b = n - ones[g - 1] - 1
				if b >= k + 1:
					ans += b // (k + 1)
			print(ans)
		elif n <= k:
			print(1)
		elif n % (k + 1) == 0:
			print(n // (k + 1))
		else:
			print(n // (k + 1) + 1)


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	arr = input()
	ans = 0
	dp = []
	dis = 0
	for (i, x) in enumerate(arr):
		if x == '1':
			if len(dp) > 0:
				dp.append(dis - 1)
			else:
				dp.append(dis)
			dis = 0
		dis += 1
	if len(dp) == 0:
		dp.append(dis)
	else:
		dp.append(dis - 1)
	if len(dp) == 1 and dp[0] == n:
		print(n // (k + 1) + (1 if n - (k + 1) * (n // (k + 1)) > 0 else 0))
	else:
		for (i, y) in enumerate(dp):
			if i == 0 and arr[0] == '0':
				x = y - k
				if x > 0:
					ans += x // (k + 1) + (1 if x - (k + 1) * (x // (k + 1)) > 0 else 0)
				continue
			elif i == len(dp) - 1:
				x = y - k
				if x > 0:
					ans += x // (k + 1) + (1 if x - (k + 1) * (x // (k + 1)) > 0 else 0)
				continue
			else:
				x = y - 2 * k
			if x < k and x > 0:
				ans += 1
			elif x > 0:
				ans += x // (k + 1) + (1 if x - (k + 1) * (x // (k + 1)) > 0 else 0)
		print(ans)


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	(n, k) = MI()
	s = SI()
	l = []
	for i in range(n):
		if s[i] == '1':
			l.append(i)
	if len(l) == 0:
		print(max(1, 1 + (n - 1) // (k + 1)))
	else:
		count = l[0] // (k + 1)
		for i in range(1, len(l)):
			count += (l[i] - l[i - 1] - 1 - k) // (k + 1)
		count += (n - l[-1] - 1) // (k + 1)
		print(count)


import sys
for i in range(int(sys.stdin.readline())):
	(n, k) = map(int, sys.stdin.readline().split())
	li = list(sys.stdin.readline())
	index = []
	cnt = 0
	for j in range(n):
		if li[j] == '1':
			index.append(j)
	if len(index) > 0:
		cnt += index[0] // (k + 1)
		cnt += (n - 1 - index[-1]) // (k + 1)
		for i in range(len(index) - 1):
			cnt += (index[i + 1] - index[i] + k + 1) // (k + 1)
			cnt -= 2
		print(cnt)
	else:
		t = (n + k) // (k + 1)
		print(t)


T = int(input())

def solve(s):
	arr = s.split('1')
	ans = 0
	for i in range(0, len(arr)):
		el = arr[i]
		l = len(el)
		if i != 0 and i != len(arr) - 1:
			l = len(el) - k
		if len(arr) == 1:
			ans = 1 + int((l - 1) / (k + 1))
			break
		ans += int(l / (k + 1))
	print(ans)
while T > 0:
	(n, k) = [int(el) for el in input().split(' ')]
	s = input()
	solve(s)
	T -= 1


def solve(line, k):
	result = 0
	list = [0 - k - 1]
	for i in range(len(line)):
		if line[i] == '1':
			list.append(i)
	list.append(len(line) + k)
	for i in range(len(list) - 1):
		result += (list[i + 1] - list[i] - 1 - k) // (k + 1)
	return result
N = int(input())
result = []
for i in range(N):
	(n, k) = (int(x) for x in input().split())
	result.append(solve(input(), k))
for i in result:
	print(i)


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	temp = input()
	s = temp.split('1')
	ans = 0
	if len(s) == 1:
		print(max(ceil(len(s[0]) / (k + 1)), 1))
	else:
		ind = []
		for i in range(n):
			if temp[i] == '1':
				ind.append(i)
		if ind[0] != 0:
			if ind[0] > k:
				ans += max(ind[0] // (k + 1), 1)
		if ind[-1] != n - 1:
			if n - ind[-1] - 1 > k:
				ans += max((n - ind[-1] - 1) // (k + 1), 1)
		for i in range(1, len(ind)):
			d = ind[i] - ind[i - 1] - 1
			if d <= 2 * k:
				continue
			else:
				ans += int(ceil((d - 2 * k) / (k + 1)))
		print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	r = 0
	c0 = 0
	for c in s:
		if c == '1':
			c0 = -k
		else:
			c0 += 1
			if c0 == k + 1:
				r += 1
				c0 = 0
	if c0 > 0:
		r += 1
	print(r)


def calc(zeros, k):
	if zeros % (k + 1) == 0:
		return zeros // (k + 1)
	else:
		return zeros // (k + 1) + 1
t = int(input())
for x in range(t):
	(n, k) = map(int, input().split(' '))
	tables = input()
	left = 0
	one = -1
	seats = 0
	for (i, t) in enumerate(tables):
		if t == '1':
			zeros = i - k - 1 - left + 1
			if zeros > 0:
				seats += calc(zeros, k)
			left = i + k + 1
	zeros = n - left
	if zeros > 0:
		seats += calc(zeros, k)
	print(seats)


n = int(input())
for w in range(n):
	(a, b) = map(int, input().split())
	(flag1, c, ans, flag2) = (0, 0, 0, 0)
	s = input()
	if s == '0':
		print(1)
	else:
		for i in range(a):
			if s[i] == '0':
				c = c + 1
			elif s[i] == '1' and flag1 == 0:
				flag1 = 1
				if c >= b:
					c = c - b
					ans = ans + (c - 1) // (b + 1) + 1
				c = 0
			elif s[i] == '1' and flag1 == 1 and (flag2 == 0):
				flag1 = 1
				if c >= 2 * b:
					c = c - 2 * b
					ans = ans + (c - 1) // (b + 1) + 1
				c = 0
		if flag1 == 1 and flag2 == 0 and (s[len(s) - 1] == '0'):
			if c >= b:
				c = c - b
				ans = ans + (c - 1) // (b + 1) + 1
		elif flag1 == 0 and flag2 == 0 and (s[len(s) - 1] == '0'):
			if c >= b:
				ans = ans + (c - 1) // (b + 1) + 1
		print(ans)


production = True
import sys, math

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for i in range(multi)]
	else:
		next_line = sys.stdin.readline()
		if input_format >= 10:
			use_list = False
			input_format = int(str(input_format)[-1])
		else:
			use_list = True
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = next_line.split()
		elif input_format == 4:
			formatted_input = (lambda x: [x[0], list(map(int, x[1:]))])(next_line.split())
		elif input_format == 5:
			formatted_input = (lambda x: [x[0], list(map(float, x[1:]))])(next_line.split())
		else:
			formatted_input = [next_line]
		return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format=0, newline=True):
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 1:
		formatted_output = '\n'.join(map(str, output_line))
	print(formatted_output, end='\n' if newline else '')

def log(*args):
	if not production:
		print('$$$')
		print(*args)

def solve():
	(n, k) = input(1)
	t = list(map(int, [x for x in input(10) if x != '\n']))
	log(n, k)
	log(t)
	c = k
	f = 0
	for i in range(n):
		log(c)
		if t[i] == 1:
			c = 0
			continue
		else:
			c += 1
		log(k * 2 + 1)
		if c == k * 2 + 1:
			f += 1
			c = k
	if c > k:
		f += 1
	out(f)
	return
for i in range(input(11)):
	solve()


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, k) = list(map(int, stdin.readline().split()))
	s = input()
	a = []
	count = 0
	for (idx, val) in enumerate(s):
		if val == '1':
			a.append(idx)
	if len(a) == 0 or a[0] > k:
		a = [0] + a
		count += 1
	if a[-1] + k < n - 1:
		a.append(n - 1)
		count += 1
	for i in range(len(a) - 1):
		count += max((a[i + 1] - k - a[i] - 1) // (k + 1), 0)
	print(count)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, k) = list(map(int, stdin.readline().rstrip().split(' ')))
	a = stdin.readline().rstrip()
	i = 0
	count = 0
	while i < n:
		if a[i] == '0':
			j = 1
			broken = False
			while i + j < n and j <= k:
				if a[i + j] == '1':
					i = i + j + k + 1
					broken = True
					break
				j += 1
			if not broken:
				count += 1
				i = i + k + 1
		elif a[i] == '1':
			i = i + k + 1
	if n <= k:
		if a.find('1') == -1:
			count = 1
		else:
			count = 0
	print(count)


num_tests = int(input())

def solve(n, k, nums):
	last_seen = k
	sol_count = 0
	for i in range(len(nums)):
		if last_seen >= 2 * k + 1:
			sol_count += 1
			last_seen = k
		if nums[i] == '1':
			last_seen = 0
		elif nums[i] == '0':
			if i == len(nums) - 1:
				if last_seen >= k:
					sol_count += 1
			last_seen += 1
	return sol_count
for test in range(num_tests):
	(n, k) = [int(x) for x in input().split(' ')]
	nums = input()
	print(solve(n, k, nums))


t = int(input())
totals = []
for i in range(t):
	line = input().split()
	n = int(line[0])
	k = int(line[1])
	line = input()
	if not '1' in line:
		totals.append(1 + (len(line) - 1) // (k + 1))
	else:
		f_s = line[0]
		l_s = line[len(line) - 1]
		line = line.split('1')
		line_f = len(line[0])
		line_l = len(line[len(line) - 1])
		q = 0
		for e in line:
			if len(e) >= k:
				q += (len(e) - k) // (k + 1)
		if line_f >= k and line_l >= k:
			q += (1 - int(f_s)) * (line_f // (k + 1) - (line_f - k) // (k + 1)) + (1 - int(l_s)) * (line_l // (k + 1) - (line_l - k) // (k + 1))
		elif line_f >= k:
			q += (1 - int(f_s)) * (line_f // (k + 1) - (line_f - k) // (k + 1)) + (1 - int(l_s)) * (line_l // (k + 1))
		elif line_l >= k:
			q += (1 - int(f_s)) * (line_f // (k + 1)) + (1 - int(l_s)) * (line_l // (k + 1) - (line_l - k) // (k + 1))
		totals.append(q)
for i in range(t):
	print(totals[i])


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = 5 * 10 ** 5 + 7
for _ in range(I()):
	(n, k) = R()
	s = S()
	a = [-(k + 1)]
	for i in range(n):
		if s[i] == '1':
			a += (i,)
	a += (n + k,)
	ans = 0
	m = 1 + k
	for i in range(1, len(a)):
		ans += (a[i] - a[i - 1] - 1 - k) // m
	print(ans)


def no_bound(zero, k):
	if zero <= 0:
		return 0
	zero += k
	return max(1, zero // (k + 1))

def one_bound(zero, k):
	zero -= k
	zero = max(0, zero)
	return no_bound(zero, k)

def two_bound(zero, k):
	zero -= 2 * k
	zero = max(zero, 0)
	return no_bound(zero, k)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	lo = -1
	fans = 0
	while lo < len(s):
		hi = lo + 1
		while hi < len(s) and s[hi] == '0':
			hi += 1
		zero = hi - lo
		if lo == -1 and hi == n:
			fans += no_bound(n, k)
		elif lo == -1 or hi == n:
			zc = hi - lo - 1
			fans += one_bound(zc, k)
		else:
			zc = hi - lo - 1
			fans += two_bound(zc, k)
		lo = hi
	print(fans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	x1 = 0
	if s[0] == '0':
		ans += 1
		x1 = 0
	for j in range(1, len(s)):
		if s[j] == '1':
			if j - x1 - k <= 0:
				ans -= 1
			x1 = j
		elif j - x1 - k > 0:
			ans += 1
			x1 = j
	print(ans)


import sys
import math
from collections import defaultdict

def solve(test):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	if '1' not in s:
		q = n // (k + 1)
		if n - (k + 1) * q > 0:
			ans = q + 1
		else:
			ans = q
		print(ans)
		return
	l = s.index('1')
	h = s[::-1].index('1')
	ans += l // (k + 1) + h // (k + 1)
	z = 0
	for i in range(l + 1, n - h):
		if s[i] == '0':
			z += 1
		else:
			q = z // (k + 1)
			if z - (k + 1) * q >= k:
				ans += q
			else:
				ans += q - 1
			z = 0
	print(ans)
test_cases = int(input())
for t in range(1, test_cases + 1):
	solve(t)


from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write
t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().strip().split(' '))
	mop = 0
	s = input()
	last = -1
	for i in range(n):
		if s[i] == '1':
			if last == -1:
				temp = i - m
				if temp > 0:
					mop += temp // (m + 1)
					r = 1 if temp % (m + 1) else 0
					mop += r
				last = i
			else:
				temp = i - last - 2 * m - 1
				if temp > 0:
					mop += temp // (m + 1)
					r = 1 if temp % (m + 1) else 0
					mop += r
				last = i
	if last == -1:
		r = 1 if n % (m + 1) else 0
		print(n // (m + 1) + r)
	else:
		temp = n - 1 - last - m
		if temp > 0:
			mop += temp // (m + 1)
			r = 1 if temp % (m + 1) else 0
			mop += r
		print(mop)


from bisect import bisect_left
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	a = [float('-inf')]
	for i in range(n):
		if s[i] == '1':
			a.append(i)
	a.append(float('inf'))
	ans = 0
	i = 0
	while i < n:
		l = bisect_left(a, i)
		next = a[l]
		last = a[l - 1]
		if i - last > k and next - i > k:
			ans += 1
			i += k
		i += 1
	print(ans)


def ints():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, k) = ints()
	s = input()
	l = []
	c = 0
	for i in range(n):
		if s[i] == '0':
			c += 1
		else:
			l.append(c)
			c = 0
	l.append(c)
	a = 2 * k + 1
	d = a // 2 + 1
	if len(l) == 1:
		print(1 + (l[0] - 1) // d)
		continue
	ans = 0
	for i in range(1, len(l) - 1):
		if l[i] < a:
			continue
		ans += (l[i] - a) // d + 1
	if l[0] > k:
		ans += (l[0] - (k + 1)) // d + 1
	if l[len(l) - 1] > k:
		ans += (l[len(l) - 1] - (k + 1)) // d + 1
	print(ans)


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	if s[0] == '1':
		pr = 0
	else:
		pr = 0
		ans += 1
	for i in range(1, n):
		if s[i] == '1' and i - pr > k:
			pr = i
		elif s[i] == '1' and i - pr <= k:
			ans -= 1
			pr = i
		elif s[i] == '0' and i - pr > k:
			ans += 1
			pr = i
	print(ans)


for _ in range(int(input())):
	prev = -1
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	output = 0
	for i in range(n):
		if s[i] == '1':
			if prev == -1:
				distance = i - prev - k - 1
				if distance > 0:
					output += 1 + (distance - 1) // (k + 1)
				prev = i
				count = i
				continue
			distance = i - prev
			distance -= 2 * k + 1
			if distance > 0:
				output += 1 + (distance - 1) // (k + 1)
			prev = i
		count = i
	distance = count - prev - k
	if prev == -1:
		distance += k
	if distance > 0:
		output += 1 + (distance - 1) // (k + 1)
	print(output)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	string = input()
	prevOff = k
	forwOff = k
	seats = 0
	prevLi = []
	forwLi = []
	for i in range(len(string)):
		if string[i] == '1':
			prevOff = 0
			prevLi.append(0)
		if string[i] == '0':
			if prevOff < k:
				prevLi.append(0)
				prevOff += 1
			elif prevOff >= k:
				prevLi.append(1)
				prevOff = 0
	for i in range(len(prevLi)):
		if prevLi[i] == 1:
			if '1' not in string[i:i + k + 1]:
				seats += 1
	print(seats)
	t -= 1


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if s == '0' * n:
		print(math.ceil(n / (k + 1)))
	else:
		left = 0
		leftIndex = 0
		for i in range(n):
			if s[i] == '0':
				left += 1
			else:
				leftIndex = i
				break
		right = 0
		rightIndex = 0
		for i in range(n - 1, -1, -1):
			if s[i] == '0':
				right += 1
			else:
				rightIndex = i
				break
		ans = left // (k + 1) + right // (k + 1)
		dist = 0
		for i in range(leftIndex, rightIndex + 1):
			if s[i] == '0':
				dist += 1
			else:
				dist -= k
				if dist > 0:
					ans += dist // (k + 1)
				dist = 0
		print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(input())
	ans = 0
	i = 0
	if l[0] == '0':
		ans += 1
	last_idx_of_one = 0
	i = 1
	while i < n:
		if l[i] == '1':
			if i - last_idx_of_one - 1 < k:
				ans -= 1
			last_idx_of_one = i
		elif i - last_idx_of_one - 1 >= k:
			ans += 1
			last_idx_of_one = i
		i = i + 1
	print(ans)


import math
x = int(input())
for i in range(x):
	(n, k) = list(map(int, input().split()))
	a = input()
	kk = 0
	ans = 0
	count = 0
	present = 0
	while kk < n:
		if a[kk] == '0':
			count += 1
			kk += 1
		else:
			present += 1
			if present == 1 and count >= k + 1:
				count -= 1
				ans += 1
				if count >= k * 2 + 1:
					count -= k
					if count >= 1:
						ans += count // (k + 1)
						count = 0
			elif count >= k * 2 + 1:
				count -= k
				if count >= 1:
					ans += count // (k + 1)
					count = 0
			count = 0
			kk += 1
	if count != 0 and present > 0:
		count -= k
		if count >= 0:
			ans += math.ceil(count / (k + 1))
	elif count != 0 and present == 0:
		ans += math.ceil(count / (k + 1))
	print(ans)


import sys

def start(s, i):
	ctr = 0
	answer = 0
	for g in range(i - 1, -1, -1):
		ctr += 1
		if ctr == k + 1:
			ctr = 0
			answer += 1
	return answer
T = int(sys.stdin.readline())
ans_arr = []
for t in range(T):
	[n, k] = [int(i) for i in sys.stdin.readline().split()]
	s = sys.stdin.readline().strip()
	arr = [-2]
	for e in range(n):
		if s[e] == '1':
			arr.append(e)
	arr.append(n)
	if len(arr) == 2:
		if n <= k + 1:
			ans_arr.append(str(1))
		else:
			ctr = 0
			answ = 1
			for g in range(1, n):
				ctr += 1
				if ctr == k + 1:
					ctr = 0
					answ += 1
			ans_arr.append(str(answ))
	else:
		ans = 0
		for w in range(len(arr) - 1):
			if w == 0:
				val = start(s, arr[w + 1])
				ans += val
			elif w == len(arr) - 2:
				val = arr[w + 1] - arr[w] - 1
				if val > 0:
					ans = ans + val // (k + 1)
			else:
				val = arr[w + 1] - k - arr[w] - 1
				if val > 0:
					ans = ans + val // (k + 1)
		ans_arr.append(str(ans))
print('\n'.join(ans_arr))


def zero(x, k):
	if x % (k + 1) != 0:
		return 1 + x // (k + 1)
	else:
		return x // (k + 1)

def max_tables(n, k, s):
	L = []
	for i in range(n):
		L.append(int(s[i]))
	ind = []
	for i in range(n):
		if L[i] == 1:
			ind.append(i)
	if len(ind) == 0:
		return zero(n, k)
	count = 0
	if ind[0] > k:
		count += zero(ind[0] - k, k)
	if ind[-1] < n - 1 - k:
		count += zero(n - 1 - ind[-1] - k, k)
	if len(ind) > 1:
		for i in range(len(ind) - 1):
			x = ind[i + 1] - ind[i] - 2 * k - 1
			count += zero(x, k)
	return count
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	print(max_tables(n, k, s))


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if '1' not in s:
		print(int(math.ceil(n / (k + 1))))
		continue
	occ = []
	for i in range(n):
		if s[i] == '1':
			occ.append(i)
	r = occ[0] // (k + 1)
	for i in range(1, len(occ)):
		c = (occ[i] - occ[i - 1]) // (k + 1)
		r += max(0, c - 1)
	r += math.ceil(max(0, n - occ[-1] - k - 1) / (k + 1))
	print(int(r))


def min(a, b):
	if a < b:
		return a
	else:
		return b

def maxify(x1, x2, k):
	print(x2, x1, k)
	count = 1
	r = x2 + (k + 1)
	while r <= x1:
		count += 1
		r = x2 + (k + 1)
	return count
t = int(input())
for i in range(0, t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	string = list(input())
	length = len(string)
	l2r = [False] * length
	r2l = [False] * length
	j1 = 0
	while j1 < length:
		if string[j1] == '0':
			l2r[j1] = True
		if string[j1] == '1':
			j1 += k
		j1 += 1
	j2 = 1
	while j2 <= length:
		if string[-j2] == '1':
			j2 += k
		else:
			r2l[-j2] = True
		j2 += 1
	j = 0
	ans = 0
	while j < length:
		if l2r[j] == True and r2l[j] == True:
			ans += 1
			for kk in range(j + 1, j + k + 1):
				if kk < length:
					l2r[kk] = False
			j += k
		j += 1
	print(ans)


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def one(x):
	if '1' in a[i + 1:min(i + k + 1, n)]:
		return a[i + 1:min(i + k + 1, n)].find('1')
	return -1
(t,) = mp()
for _ in range(t):
	(n, k) = mp()
	a = cin()[:-1]
	count = i = 0
	while i < n:
		if a[i] == '0':
			z = a[i + 1:min(i + k + 1, n)].rfind('1')
			if z == -1:
				count += 1
				i += k + 1
			else:
				i += z + 1
		else:
			y = a[i + 1:min(i + k + 1, n)].rfind('1')
			if y == -1:
				i += k + 1
			else:
				i += y + k + 2
	cout(str(count) + '\n')


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 200010
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]
spf[0] = spf[1] = -1

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()
for _ in range(int(input())):
	(n, k) = arrIN()
	s = input()
	a = [i for i in range(n) if s[i] == '1']
	a = [-1 - k] + a + [n + k]
	ans = 0
	for i in range(len(a) - 1):
		d = a[i + 1] - a[i]
		d -= k + 1
		ans += d // (k + 1)
	print(ans)


from bisect import bisect_left
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s = '1' + '0' * k + s + '0' * k + '1'
	n = len(s)
	next = []
	for i in range(n):
		if s[i] == '1':
			next.append(i)
	nl = len(next)
	ans = 0
	for i in range(n):
		if s[i] == '1':
			index = bisect_left(next, i) + 1
			if index == nl:
				continue
			ni = next[index]
			ans += (ni - i - 1 - k) // (k + 1)
	print(ans)


def f(n, k):
	ans = 0
	count = 0
	c = 0
	p = 0
	if n % (k + 1) != 0:
		ans += n // (k + 1) + 1
	else:
		ans += n // (k + 1)
	return ans
t = int(input())
for _ in range(0, t):
	(n, k) = map(int, input().strip().split(' '))
	st = str(input())
	ans = 0
	count = 0
	c = 0
	p = 0
	q = []
	for i in range(0, n):
		if st[i] == '1':
			if count > 0:
				q.append(count)
			c = 1
			count = 0
			p = 1
		elif c == 1 and st[i] == '0':
			count += 1
	initial = 0
	end = 0
	for i in range(0, n):
		if st[i] == '0':
			initial += 1
		else:
			break
	for i in range(n - 1, -1, -1):
		if st[i] == '0':
			end += 1
		else:
			break
	for i in range(0, len(q)):
		m = q[i] - 2 * k
		if m > 0:
			ans += f(m, k)
	if st.count('1') == 0:
		ans += f(initial, k)
	else:
		if initial - k > 0:
			ans += f(initial - k, k)
		if end - k > 0 and st.count('1') != 0:
			ans += f(end - k, k)
	if ans == 0 and st.count('1') == 0:
		print(1)
	else:
		print(ans)


def solve(n, k, s):
	i = new_customer_count = 0
	while i < n:
		if s[i] == '0':
			is_block_of_k_tables_occupied = False
			for j in range(i + 1, min(i + k + 1, n)):
				if s[j] == '1':
					i = j
					is_block_of_k_tables_occupied = True
					break
			if not is_block_of_k_tables_occupied:
				new_customer_count += 1
				i += k + 1
		else:
			i += k + 1
	return new_customer_count
t = int(input())
results = list()
for _ in range(0, t):
	(n, k) = map(int, input().split(' '))
	s = input()
	results.append(solve(n, k, s))
for result in results:
	print(result)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	c = k
	for i in range(n):
		if s[i] == '0':
			c += 1
		else:
			t = (c - k) // (k + 1)
			if t > 0:
				count += t
			c = 0
	t = c // (k + 1)
	if t > 0:
		count += t
	print(count)


t = int(input())
for i in range(0, t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	s = input()
	l = []
	r = 0
	for j in range(0, n):
		if s[j] == '0':
			r = r + 1
			if j == n - 1:
				r = r + k
			if j == 0:
				r = r + k
		else:
			l.append(r)
			r = 0
	l.append(r)
	g = 0
	for j in range(0, len(l)):
		if l[j] > k + 1:
			g = g + (l[j] - k) // (k + 1)
	print(g)


import math
k = []
s = []
t = int(input())
for _ in range(t):
	k.append(list(map(int, input().split()))[1])
	s.append(input())
for t in range(t):
	ans = 0
	if '1' not in s[t]:
		if len(s[t]) <= k[t] + 1:
			print('1')
		else:
			print(int(math.ceil(len(s[t]) / (k[t] + 1))))
	else:
		ss = 0
		if '1' not in s[t][:k[t] + 1]:
			s[t] = '1' + s[t][1:]
			ans += 1
		ss += k[t] + 1
		while ss <= len(s[t]) - 1:
			if '1' not in s[t][ss - k[t]:ss + k[t] + 1]:
				s[t] = s[t][:ss] + '1' + s[t][ss + 1:]
				ss += k[t] + 1
				ans += 1
			else:
				ss += 1
		print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	a = []
	a.append(n + k + 1)
	for i in range(n - 2, -1, -1):
		if s[i + 1] == '1':
			a.append(i + 1)
		else:
			a.append(a[-1])
	a = a[::-1]
	i = 0
	count = 0
	while i < n:
		if s[i] == '1':
			i = i + k + 1
			continue
		elif a[i] - i > k:
			count += 1
			i = i + k + 1
			continue
		else:
			i = a[i]
	print(count)


t = int(input())
for i in range(t):
	(n, k) = [int(n) for n in input().split()]
	s = input()
	vec = [0] * n
	for i in range(n):
		if s[i] == '1':
			for j in range(i - k, i + k + 1):
				if j >= 0 and j < n:
					vec[j] = 1
	c = 0
	for i in range(n):
		if vec[i] != 1:
			vec[i] = 1
			c = c + 1
			for j in range(i - k, i + k + 1):
				if j >= 0 and j < n:
					vec[j] = 1
	print(c)


import math
a = int(input())
for i in range(a):
	(x, k) = map(int, input().split())
	s = input()
	ans = []
	for i in range(len(s)):
		if s[i] == '1':
			ans.append(i)
	if len(ans) >= 2:
		c1 = 0
		for i in range(1, len(ans)):
			if ans[i] - ans[i - 1] - 1 >= 2 * k + 1:
				temp = ans[i] - ans[i - 1] - 1
				temp -= 2 * k + 1
				c1 += 1 + temp // (k + 1)
		i = ans[0]
		while i >= 0:
			i -= k + 1
			if i >= 0:
				c1 += 1
		i = ans[-1]
		while i < len(s):
			i += k + 1
			if i < len(s):
				c1 += 1
		print(c1)
	if len(ans) == 1:
		c1 = 0
		i = ans[0]
		while i >= 0:
			i -= k + 1
			if i >= 0:
				c1 += 1
		i = ans[-1]
		while i < len(s):
			i += k + 1
			if i < len(s):
				c1 += 1
		print(c1)
	if len(ans) == 0:
		c1 = 0
		temp = [0 for i in range(len(s))]
		i = 0
		while i < len(temp):
			c1 += 1
			temp[i] = 1
			i += k + 1
		print(c1)


import sys, math, heapq, copy
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import permutations, combinations, combinations_with_replacement
mod = 1000000007

def get_int():
	return int(sys.stdin.readline().strip())

def get_str():
	return sys.stdin.readline().strip()

def get_float():
	return float(sys.stdin.readline().strip())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_strs():
	return map(str, sys.stdin.readline().strip().split())

def get_floats():
	return map(float, sys.stdin.readline().strip().split())

def list_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def list_strs():
	return list(map(str, sys.stdin.readline().strip().split()))

def list_floats():
	return list(map(float, sys.stdin.readline().strip().split()))
t = get_int()
for _ in range(t):
	(n, k) = get_ints()
	s = list(get_str())
	l = [-1] * n
	r = [-1] * n
	x = -1
	for i in range(n):
		l[i] = x
		if s[i] == '1':
			x = i
	x = -1
	for i in range(n - 1, -1, -1):
		r[i] = x
		if s[i] == '1':
			x = i
	ans = i = 0
	while i < n:
		if s[i] == '0':
			left = right = False
			if l[i] == -1 or l[i] < i - k:
				left = True
			if r[i] == -1 or r[i] > i + k:
				right = True
			if left and right:
				ans += 1
				s[i] = '1'
				i += k + 1
			else:
				i += 1
		else:
			i += k + 1
	print(ans)


import itertools
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	inp = list(map(int, list(input())))
	tables = []
	for (table, group) in itertools.groupby(inp):
		tables.append([table, len(list(group))])
	cnt = 0
	m = len(tables)
	for (i, t) in enumerate(tables):
		if i == 0 and m == 1 and (t[0] == 0):
			if t[1] <= k:
				cnt = 1
			else:
				while t[1] > 0:
					cnt += 1
					t[1] -= k + 1
		elif i == 0 and t[0] == 0 and (t[1] > k):
			while t[1] > k:
				cnt += 1
				t[1] -= k + 1
		elif i == m - 1 and t[0] == 0 and (t[1] > k):
			while t[1] > k:
				cnt += 1
				t[1] -= k + 1
		elif t[0] == 0 and t[1] > 2 * k:
			t[1] -= k
			while t[1] > k:
				cnt += 1
				t[1] -= k + 1
	print(cnt)


import math
for i in range(int(input())):
	(n, k) = (int(i) for i in input().split())
	a = list(input())
	n = len(a)
	p = []
	c = 0
	for i in range(n):
		if i == 0 and a[i] == '1':
			c = 1
		if a[i] == '1' and i != 0:
			p.append(i - c)
			c = i + 1
	p.append(n - c)
	count = 0
	for i in p:
		if i >= k * 2 + 1:
			count += (i - k) // (k + 1)
	if a[0] == '0':
		if p[0] >= k * 2 + 1:
			count -= (p[0] - k) // (k + 1)
		count += p[0] // (k + 1)
	if a[-1] == '0':
		if p[-1] >= k * 2 + 1:
			count -= (p[-1] - k) // (k + 1)
		count += p[-1] // (k + 1)
	if len(p) == 1 and p[0] == n and (k >= n):
		print(1)
	elif len(p) == 1 and p[0] == n:
		print(1 + (n - 1) // (k + 1))
	else:
		print(count)


ll = lambda : list(map(int, input().split()))
st = lambda : input()
v = lambda : map(int, input().split())
ii = lambda : int(input())
from collections import *
for _ in range(ii()):
	(a, k) = v()
	l = list(st())
	f = -1
	c = 0
	x = 0
	i = 1
	if l[0] == '0':
		c += 1
	while i < a:
		if l[i] == '1':
			if i - x <= k:
				c -= 1
			x = i
		elif i - x > k:
			c += 1
			x = i
		i += 1
	print(c)


t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	s = input()
	lst = list(s)
	lst = [int(lst[j]) for j in range(len(lst))]
	b = []
	count = 0
	for (index, nums) in enumerate(lst):
		if nums == 1:
			b.append(index)
	if len(b) == 0:
		count = 1 + (n - 1) // (k + 1)
	else:
		for i in range(len(b) - 1):
			count += (b[i + 1] - b[i] - 1 - k) // (k + 1)
		count += b[0] // (k + 1)
		count += (n - b[-1] - 1) // (k + 1)
	print(count)


a = int(input())
for x in range(a):
	a = [int(x) for x in input().split()]
	b = str(input()) + '0' * a[1]
	answer = 0
	count = a[1]
	for x in range(len(b)):
		if b[x] == '0':
			count += 1
			if count == 2 * a[1] + 1:
				answer += 1
				if answer == 1:
					count = a[1]
				else:
					count -= a[1] + 1
		else:
			count = 0
	print(answer)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = list(map(int, input()))
		if a.count(1) == 0:
			ans = 0
			for i in range(0, n, k + 1):
				ans += 1
			print(ans)
			continue
		ss = []
		for (i, x) in enumerate(a):
			if x == 1:
				ss.append(i)
		start = 0
		ans = 0
		for x in ss:
			temp = 0
			if a[start] == 1:
				for i in range(start + k + 1, x - k, k + 1):
					ans += 1
					temp += 1
			else:
				for i in range(start, x - k, k + 1):
					ans += 1
					temp += 1
			start = x
		if a[-1] == 1:
			for i in range(ss[-1] + k + 1, n - 1 - k, k + 1):
				ans += 1
		else:
			for i in range(ss[-1] + k + 1, n, k + 1):
				ans += 1
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	s = input()
	i = 0
	j = 0
	cnt = 0
	while i < n:
		if s[i] == '1':
			prev = i
			break
		else:
			cnt += 1
			prev = i
			break
		i += 1
	j = i + 1
	while j < n:
		if s[j] == '0':
			if j - prev - 1 >= k:
				prev = j
				cnt += 1
		else:
			if j - prev - 1 < k:
				cnt -= 1
			prev = j
		j += 1
	print(cnt)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [x for x in input()]
	ans = []
	c = 0
	for i in range(len(l)):
		if l[i] == '1':
			ans.append(i)
	if len(ans) != 0:
		if ans[0] - k > 0:
			ans.insert(0, 0)
			c += 1
	else:
		ans.append(0)
		c += 1
	while True:
		if ans[-1] + k < len(l) - 1:
			ans.append(len(l) - 1)
			c += 1
		else:
			break
	for i in range(1, len(ans)):
		a = (ans[i] - ans[i - 1] - k - 1) // (k + 1)
		if a > 0:
			c += a
	print(c)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	temp = k
	for i in s:
		if not int(i):
			temp += 1
			if temp - 1 == k:
				ans += 1
				temp = 0
		else:
			if temp < k:
				ans -= 1
			temp = 0
	print(ans)


def arrange(size, space, seq):
	if size <= 2:
		if '1' in seq:
			return 0
		else:
			return 1
	current = 0
	tables = 0
	while current < size:
		dist = space + 1
		if seq[current] == '0':
			cur_seq = seq[current:current + dist]
			if '1' in cur_seq:
				current = current + cur_seq.find('1')
			else:
				tables = tables + 1
				current = current + dist
		else:
			current = current + dist
	return tables
n = int(input())
for _ in range(n):
	ss = input().split(' ')
	seq = input()
	print(arrange(int(ss[0]), int(ss[1]), seq))


def main():
	(n, k) = map(int, input().split(' '))
	s = list(map(len, input().split('1')))
	if k == 0:
		return sum(s)
	if len(s) == 0:
		return 0
	if len(s) == 1:
		return (s[0] + k) // (k + 1)
	free = 0
	if len(s) > 2:
		for x in s[1:-1]:
			if x > k:
				free += (x - k) // (k + 1)
	free += s[0] // (k + 1)
	if len(s) > 1:
		free += s[-1] // (k + 1)
	return free
for _ in range(int(input())):
	print(main())


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	zeroes = []
	oneexists = False
	zeroexists = False
	if s[0] == '0':
		z = 1
		zeroexists = True
	else:
		z = 0
		oneexists = True
	for i in range(1, len(s)):
		if s[i] == '1':
			oneexists = True
			if s[i - 1] == '0':
				zeroes.append(z)
				z = 0
		else:
			zeroexists = True
			z += 1
	if z > 0:
		zeroes.append(z)
	if not zeroexists:
		print(0)
		continue
	if not oneexists:
		print(1 + (zeroes[0] - 1) // (k + 1))
	else:
		total = 0
		for j in range(len(zeroes)):
			if j == 0 and s[0] == '0':
				total += zeroes[j] // (k + 1)
			elif j == len(zeroes) - 1 and s[-1] == '0':
				total += zeroes[j] // (k + 1)
			elif zeroes[j] >= k:
				total += (zeroes[j] - k) // (k + 1)
		print(total)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, k) = LI()
		s = S()
		t = 0
		a = []
		for c in s:
			if c == '1':
				a.append(t)
				t = 0
			else:
				t += 1
		a.append(t)
		a[0] += k
		a[-1] += k
		r = 0
		for c in a:
			t = (c + 1) // (k + 1) - 1
			if t > 0:
				r += t
		rr.append(r)
	return JA(rr, '\n')
print(main())


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, list(input())))
	if 1 not in l:
		print(len(l) // (k + 1) + (1 if len(l) % (k + 1) else 0))
	else:
		sits = 0
		slot = 0
		if l[0] == 0:
			for i in range(l.index(1)):
				slot += 1
			slot -= k
			sits += slot // (k + 1) + (1 if slot % (k + 1) else 0)
			slot = 0
			l = l[l.index(1):]
		l.reverse()
		if l[0] == 0:
			for i in range(l.index(1)):
				slot += 1
			slot -= k
			sits += slot // (k + 1) + (1 if slot % (k + 1) else 0)
			slot = 0
			l = l[l.index(1):]
		l.reverse()
		for i in range(len(l)):
			if l[i] == 1:
				slot -= 2 * k
				slot = slot if slot > 0 else 0
				sits += slot // (k + 1) + (1 if slot % (k + 1) else 0)
				slot = 0
			else:
				slot += 1
		print(sits)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	st = list(input())
	if n == 1 and st == '0':
		print(1)
		t -= 1
		continue
	if n == 1 and st == '1':
		print(0)
		t -= 1
		continue
	ans = 0
	a = k + 1 + k
	(i, j) = (0, 0)
	lst_1 = [-k - 1]
	for (i, v) in enumerate(st):
		if v == '1':
			lst_1.append(i)
	lst_1.append(n + k)
	diff = []
	for i in range(1, len(lst_1)):
		b = lst_1[i] - lst_1[i - 1] - 1
		if b >= k:
			diff.append(b)
	for i in diff:
		d = i - a
		if d >= 0:
			ans += 1
		if d >= 0:
			e = d // (k + 1)
			ans += e
	print(ans)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	if s.find('1') > k or '1' not in s:
		s = '1' + s[1:]
		count += 1
	if n - s.rfind('1') - 1 > k:
		s = s[:-1] + '1'
		count += 1
	i = s.find('1')
	while i < n:
		t = i
		i += 1
		while i < n and s[i] != '1':
			i += 1
		if i - t - 1 > k:
			count += (i - t - 1 - k) // (k + 1)
	print(count)


T = int(input())

def main():
	(n, k) = tuple(map(int, input().split()))
	s = input()
	x = [0] * n
	for i in range(n):
		if s[i] == '1':
			x[max(0, i - k):i + k + 1] = [1] * len(x[max(0, i - k):i + k + 1])
		else:
			continue
	pointer = 0
	count = 0
	while pointer < n:
		if x[pointer] != 1:
			count = count + 1
			pointer = pointer + k + 1
		else:
			pointer = pointer + 1
	return count
for i in range(T):
	print(main())


def solve(n, k, s):
	nextone = [-1] * n
	last = float('inf')
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			last = i
		nextone[i] = last
	prev = float('-inf')
	sol = 0
	for i in range(n):
		if s[i] == '1':
			prev = i
		elif i - prev > k and nextone[i] - i > k:
			sol += 1
			prev = i
	return sol
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	print(solve(n, k, s))


import math

def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		(n, k) = [int(x) for x in input().split()]
		s = input()
		if s.count('1') == 0:
			if len(s) <= k:
				print(1)
			else:
				print(math.ceil(len(s) / (k + 1)))
			continue
		ans = 0
		temp = str(s)
		temp = temp.lstrip('0')
		ans += (n - len(temp)) // (k + 1)
		n = len(temp)
		temp = temp.rstrip('0')
		ans += (n - len(temp)) // (k + 1)
		temp = temp.split('1')
		mids = []
		for x in temp:
			if len(x) > 1:
				mids.append(x)
		for m in mids:
			prev = -1
			last = len(m)
			i = 0
			while i < len(m):
				if i - k > prev and i + k < last:
					ans += 1
					prev = i
				i += 1
		print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


inf = float('inf')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	one = inf
	new = []
	for i in range(n):
		if a[i] == '1':
			new.append(1)
			one = i
		elif abs(i - one) <= k:
			new.append(1)
		else:
			new.append(0)
	for i in range(n - 1, -1, -1):
		if a[i] == '1':
			one = i
		elif abs(i - one) <= k:
			new[i] = 1
	ans = 0
	m = 0
	for i in range(n):
		if new[i] == 0:
			m += 1
		else:
			ans += (m + k) // (1 + k)
			m = 0
	ans += (m + k) // (1 + k)
	print(ans)


t = int(input())
for _ in range(t):
	[n, k] = [int(x) for x in input().split()]
	string = input()
	n = len(string)
	prev = -k - 1
	count = 0
	for i in range(n):
		if string[i] == '0':
			if i - prev - 1 >= k:
				count += 1
				prev = i
		else:
			if i - prev - 1 < k:
				count -= 1
			prev = i
	print(count)


from math import radians
from heapq import heapify, heappush, heappop
import bisect
from math import pi
from collections import deque
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li1():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def treeOrderByDepth(n, adj, root=0):
	parent = [-2] + [-1] * (n - 1)
	ordered = []
	q = deque()
	q.append(root)
	depth = [0] * n
	while q:
		c = q.popleft()
		ordered.append(c)
		for a in adj[c]:
			if parent[a] == -1:
				parent[a] = c
				depth[a] = depth[c] + 1
				q.append(a)
	return (ordered, parent, depth)

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def nextPowerOf2(n):
	count = 0
	if n and (not n & n - 1):
		return n
	while n != 0:
		n >>= 1
		count += 1
	return 1 << count
for _ in range(ii()):
	(n, k) = mi()
	l = si()
	ind = []
	for i in range(n):
		if l[i] == '1':
			ind.append(i + 1)
	c = 0
	l = list(l)
	if len(ind) == 0:
		print(int(ceil(n / (k + 1))))
		continue
	(x, y) = (1, 1)
	if ind[0] != 1:
		ind.insert(0, 1)
		x = 0
	if ind[-1] != n:
		ind.append(n)
		y = 0
	for i in range(1, len(ind)):
		z = 2
		if x == 0 and ind[i - 1] == 1:
			z = 1
		elif x == 0 and y == 0 and (ind[i] == n) and (ind[i - 1] == 1):
			z = 0
		elif y == 0 and ind[i] == n:
			z = 1
		c += max(0, int(ceil((ind[i] - ind[i - 1] + 1) / (k + 1))) - z)
	print(c)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	(n, k) = map(int, input().split())
	string1 = [k for k in input()]
	pos = []
	for s in range(n):
		if string1[s] == '1':
			pos.append(s)
	pos.reverse()
	cv = 0
	count = 0
	while cv < n:
		nex = cv + k + 1
		if len(pos) != 0:
			if pos[-1] >= nex:
				if string1[cv] == '0':
					string1[cv] = '1'
					count += 1
				cv += k + 1
			else:
				cv = pos.pop()
		else:
			if string1[cv] == '0':
				string1[cv] = '1'
				count += 1
			cv += k + 1
	print(count)


def main():
	(n, k) = map(int, input().split())
	str1 = list(str(input()))
	dp = [0 for _ in range(n + 1)]
	for i in range(n):
		dp[i + 1] = dp[i] + (str1[i] == '1')
	i = 1
	ans = 0
	while i < n + 1:
		if dp[min(i + k, n)] - dp[max(i - k - 1, 0)] == 0:
			ans += 1
			i += k + 1
		else:
			i += 1
	print(ans)
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


p = int(input())
arr = []
for i in range(p):
	(n, k) = map(int, input().split())
	t = str(input())
	array = [d for d in t.split('1')]
	count = 0
	for j in range(len(array)):
		if len(array) == 1:
			count_1 = 0
			for b in range(0, len(array[0]), k + 1):
				count_1 += 1
			count += count_1
		elif j == 0 and array[0] != '' or (j == len(array) - 1 and array[len(array) - 1] != ''):
			r = len(array[j]) - k
			if r > 0:
				count_1 = 0
				for b in range(0, r, k + 1):
					count_1 += 1
				count += count_1
		else:
			r = len(array[j]) - 2 * k
			if r > 0:
				count_1 = 0
				for b in range(0, r, k + 1):
					count_1 += 1
				count += count_1
	arr.append(count)
for j in range(len(arr)):
	print(arr[j])


for i in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	ar = input().strip()
	a = list(ar)
	ans = 0
	idx = 0
	while idx < n:
		if a[idx] == '1':
			strt = idx - k
			end = idx + k
			if strt <= 0:
				strt = 0
			if end >= n:
				end = n - 1
			for i in range(strt, end + 1):
				a[i] = '2'
		idx += 1
	for i in range(0, n):
		if a[i] == '0':
			ans += 1
			end = i + k
			if end >= n:
				end = n - 1
			for j in range(i, end + 1):
				a[j] = '2'
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	size = k
	count = 0
	for i in range(n):
		if s[i] == '0':
			size += 1
		else:
			size = 0
		if size == 2 * k + 1:
			count += 1
			size = k
	if size >= k + 1:
		count += 1
	print(count)


import sys
from collections import defaultdict as dd
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	w = input()
	a = -1
	b = 0
	e = 0
	i = 0
	while w[i] == '0' and i < n - 1:
		i += 1
	b += i // (k + 1)
	a = i - 1
	for i in range(i, n):
		if w[i] == '1':
			e = 1
			b += max((i - a - 1) // (k + 1) if (i - a - 1) % (k + 1) == k else (i - a - 1) // (k + 1) - 1, 0)
			a = i
	b += (n - a - 1) // (k + 1)
	if e == 0:
		b = max(n // (k + 1) if n % (k + 1) == 0 else n // (k + 1) + 1, 1)
	print(b)


import math

def fun(a, k):
	x = [i for i in range(len(a)) if a[i] == '1']
	count = 0
	if len(x) == 0:
		return math.ceil(len(a) / (k + 1))
	r = x[0] - k
	if r > 0:
		count += math.ceil(r / (k + 1))
	if x[-1] != len(a) - 1:
		r = len(a) - x[-1] - 1 - k
		if r > 0:
			count += math.ceil(r / (k + 1))
	for i in range(len(x) - 1):
		r = x[i + 1] - x[i] - 1 - 2 * k
		if r > 0:
			count += math.ceil(r / (k + 1))
	return count
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = input()
	print(fun(a, k))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	(cur, res) = (k, 0)
	(i, e) = (0, 0)
	while e < n:
		if s[e] == '1':
			if i == 0:
				res += (e - i) // (k + 1)
			else:
				res += max((e - i - k) // (k + 1), 0)
			e = e + 1
			i = e
		else:
			e += 1
	res += (e - i) // (k + 1)
	if i == 0:
		res = (e - 1) // (k + 1) + 1
	print(res)


import math
import bisect
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
T = int(input())
for t in range(T):
	(N, K) = map(int, input().split())
	S = insr()
	prev = -K - 1
	ans = 0
	fl = True
	f2 = False
	for i in range(N):
		if S[i] == '0':
			if fl == False:
				fl = True
				prev = i - 1
			if fl and i - prev >= K + 1:
				ans += 1
				prev = i
				f2 = True
		else:
			fl = False
			if f2 and i - prev < K + 1:
				ans -= 1
				f2 = False
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = ['1'] + ['0'] * k + list(input()) + ['0'] * k + ['1']
	ans = 0
	d = []
	for i in range(len(arr)):
		if arr[i] == '1':
			d.append(i)
	i = 0
	while i < len(d) - 1:
		if d[i + 1] - d[i] > 2 * k + 1:
			ans += 1
			d[i] = d[i] + k + 1
		else:
			i += 1
	print(ans)


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = input()
	ind = []
	for i in range(n):
		if l[i] == '1':
			ind.append(i + 1)
	c = 0
	l = list(l)
	if len(ind) == 0:
		print(int(ceil(n / (k + 1))))
		continue
	(x, y) = (1, 1)
	if ind[0] != 1:
		ind.insert(0, 1)
		x = 0
	if ind[-1] != n:
		ind.append(n)
		y = 0
	for i in range(1, len(ind)):
		z = 2
		if x == 0 and ind[i - 1] == 1:
			z = 1
		elif x == 0 and y == 0 and (ind[i] == n) and (ind[i - 1] == 1):
			z = 0
		elif y == 0 and ind[i] == n:
			z = 1
		c += max(0, int(ceil((ind[i] - ind[i - 1] + 1) / (k + 1))) - z)
	print(c)


for t in range(int(input())):
	(nn, k) = map(int, input().split())
	s = input()
	arr = list()
	for i in range(0, nn):
		if s[i] == '1':
			arr.append(i)
	(p, p_i) = (-100000, -1)
	if len(arr) == 0:
		n = 1000000000000
	else:
		(n, n_i) = (arr[0], 0)
	ans = 0
	for i in range(nn):
		if i > n:
			if n_i < len(arr) - 1:
				p = n
				p_i = n_i
				n_i += 1
				n = arr[n_i]
			else:
				p = n
				n = 1000000000000
				p_i = n_i
		if abs(i - p) > k and abs(i - n) > k:
			p = i
			ans += 1
	print(ans)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(n, k) = iia()
	s = list(map(int, list(is1())))
	cur = 0
	res = [0] * n
	for i in range(n):
		if s[i] == 1:
			cur = k
			res[i] = 1
		elif cur > 0:
			res[i] = 1
			cur -= 1
	for i in range(n)[::-1]:
		if s[i] == 1:
			cur = k
			res[i] = 1
		elif cur > 0:
			res[i] = 1
			cur -= 1
	ans = 0
	i = 0
	while i < len(res):
		if res[i] == 0:
			ans += 1
			i += k + 1
		else:
			i += 1
	print(ans)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	count = 0
	s = input()
	ll = list(s)
	onee = s.find('1')
	if onee != -1:
		if onee - k >= k + 1:
			count += max(0, math.ceil((onee - k) / (k + 1)))
		else:
			count += 1 if onee - k > 0 else 0
		s = s[onee + 1:]
		while s.find('1') != -1:
			onee = s.find('1')
			if onee != -1:
				if onee - 2 * k >= k + 1:
					count += max(0, math.ceil((onee - 2 * k) / (k + 1)))
				else:
					count += 1 if onee - 2 * k > 0 else 0
			s = s[onee + 1:]
		if len(s) - k >= k + 1:
			count += max(0, math.ceil((len(s) - k) / (k + 1)))
		else:
			count += 1 if len(s) - k > 0 else 0
	else:
		count += max(0, math.ceil(n / (k + 1)))
	print(count)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(str(input()))
	ans = []
	op = -1
	for i in range(n):
		if arr[i] == '1':
			ans.append(i - op - 1)
			op = i
	ans.append(n - op - 1)
	pp = 0
	if len(ans) == 1:
		pp = 1
		pp += (n - 1) // (k + 1)
	else:
		pp += ans[0] // (k + 1)
		pp += ans[-1] // (k + 1)
		for i in range(1, len(ans) - 1):
			pp += (ans[i] - k) // (k + 1)
	print(pp)


t = int(input())
while t != 0:
	t -= 1
	(n, k) = map(int, input().split())
	s = input()
	lt = [-1]
	for i in range(n):
		if s[i] == '1':
			lt.append(i)
	lt.append(n)
	if len(lt) == 2:
		ans = n // (k + 1)
		if n % (k + 1) != 0:
			ans += 1
		print(ans)
	else:
		ans = 0
		for i in range(1, len(lt)):
			(a, b) = (lt[i - 1], lt[i])
			if a == -1 or b == n:
				d = b - a - k - 1
			else:
				d = b - a - 2 * k - 1
			aux = 0
			if 1 <= d <= k:
				aux = 1
			elif d >= k + 1:
				aux = d // (k + 1)
				if d % (k + 1) != 0:
					aux += 1
			ans += aux
		print(ans)


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	s = input()
	l = []
	for i in range(n):
		if s[i] == '1':
			l.append(i)
	if k >= n:
		if not l:
			print(1)
		else:
			print(0)
	elif not l:
		r = n // (k + 1)
		if n % (k + 1):
			r += 1
		print(r)
	else:
		res = 0
		(first, last) = (l[0], l[-1])
		for i in range(first - k - 1, -1, -(k + 1)):
			res += 1
		for i in range(last + k + 1, n, k + 1):
			res += 1
		m = len(l)
		for i in range(m - 1):
			(left, right) = (l[i], l[i + 1])
			(v1, v2) = (left + k + 1, right - k - 1)
			if v1 < right and v2 > left and (v2 >= v1):
				d = v2 - v1 + 1
				res += d // (k + 1)
				if d % (k + 1):
					res += 1
		print(res)


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


def find_count(s, i, j, k, v):
	n = 0
	if v == 'left':
		for _ in range(i, j - k + 1, k):
			n += 1
	elif v == 'right':
		for _ in range(i + k - 1, j, k):
			n += 1
	elif v == 'mid':
		for _ in range(i + k - 1, j - k + 1, k):
			n += 1
	else:
		for _ in range(i, j, k):
			n += 1
	return n

def eval(n, k, s):
	i = 0
	m = 0
	while i < len(s):
		if s[i] == '0':
			j = i
			while j < len(s) and s[j] == '0':
				j += 1
			if i == 0 and j == len(s):
				m += find_count(s, i, j, k + 1, 'all')
			elif i == 0:
				m += find_count(s, i, j, k + 1, 'left')
			elif j == len(s):
				m += find_count(s, i, j, k + 1, 'right')
			else:
				m += find_count(s, i, j, k + 1, 'mid')
			i = j
		else:
			i += 1
	return m
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = input()
	print(eval(n, k, s))


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	(n, k) = mi()
	ones = 0
	a = list(input())
	latest = -1
	ne = [-1] * n
	ans = 0
	for i in range(n - 1, -1, -1):
		a[i] = int(a[i])
		if a[i] == 1:
			ones += 1
			latest = i
		if latest != -1:
			ne[i] = latest - i
	latest = -1
	for i in range(n):
		a[i] = int(a[i])
		if a[i] == 0:
			if ne[i] == -1 or ne[i] > k:
				if i - latest > k or latest == -1:
					ans += 1
					a[i] = 1
					latest = i
		else:
			latest = i
	print(ans)


from sys import stdin, stdout
for query in range(int(stdin.readline())):
	nk = stdin.readline().split()
	n = int(nk[0])
	k = int(nk[1])
	s = [int(x) for x in list(stdin.readline().strip())]
	a = [0] * n
	total = 0
	count = 0
	for table in range(n):
		if s[table] == 1:
			a[table] = 1
			count = k
		elif count > 0:
			a[table] = 1
			count -= 1
	count = 0
	for table in range(n - 1, -1, -1):
		if s[table] == 1:
			a[table] = 1
			count = k
		elif count > 0:
			a[table] = 1
			count -= 1
	count = 0
	for table in range(n):
		if a[table] == 0 and count == 0:
			count = k
			total += 1
		elif count > 0:
			count -= 1
	stdout.write(str(total) + '\n')


import math
n = int(input())
for _ in range(n):
	(n, k) = map(int, input().split())
	s = input()
	zeros = s.split('1')
	seats = 0
	if len(zeros) == 1 and zeros[0] != '':
		seats = math.ceil(len(zeros[0]) / (k + 1))
	else:
		for (i, z) in enumerate(zeros):
			if z == '':
				continue
			l = len(z)
			if i == 0 or i == len(zeros) - 1:
				seats += math.ceil((l - k) / (k + 1))
			else:
				seats += math.ceil((l - 2 * k) / (k + 1))
	print(seats)


t = int(input())
for s in range(t):
	(n, m) = map(int, input().split())
	array = input()
	rama = []
	for i in array:
		rama.append(int(i))
	j = 1
	shiv = [0]
	for i in rama:
		if i == 1:
			shiv.append(j)
		j += 1
	l = len(shiv)
	shiv.append(n + 1)
	plus = 0
	(add, d) = (1, 1)
	if l == 1:
		if shiv[1] - shiv[0] >= m + 2:
			c = shiv[1] - shiv[0] - 1
			add = 2
			while True:
				if d * m + (d + 1) > c:
					break
				d += 1
				add += 1
			plus += add - 1
		else:
			plus = 1
	else:
		for i in range(1, l + 1):
			(add, d) = (1, 1)
			if i == 1 or i == l:
				if shiv[i] - shiv[i - 1] > m:
					c = shiv[i] - shiv[i - 1] - 1
					while True:
						if d * m + d > c:
							break
						d += 1
						add += 1
					plus += add - 1
			elif shiv[i] - shiv[i - 1] > 2 * m:
				c = shiv[i] - shiv[i - 1] - 1
				while True:
					if (d + 1) * m + d > c:
						break
					d += 1
					add += 1
				plus += add - 1
	print(plus)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in list(input())]
	t = 0
	le = 0
	r = 1
	y = [-1000000]
	for i in range(n):
		if a[i] == 1:
			y.append(i)
	y.append(1000000000)
	for i in range(n):
		if a[i] == 0 and abs(y[le] - i) > k and (abs(y[r] - i) > k):
			t += 1
			y.insert(r, i)
			le += 1
			r += 1
		if i >= y[r]:
			if len(y) - 1 > r:
				r += 1
				le += 1
	print(t)


t = int(input())
b = []
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	a = [0 for i in range(n)]
	for j in range(n):
		if s[j] == '1':
			a[j] = '*'
			for z in range(1, k + 1):
				if j + z < n:
					a[j + z] = '*'
				if j - z >= 0:
					a[j - z] = '*'
	v = 0
	p = 0
	while v < n:
		if a[v] == 0:
			p += 1
			v += k
		v += 1
	b.append(p)
for h in range(t):
	print(b[h])


import sys, math, cmath, time
start_time = time.time()

def solve():
	(n, k) = invr()
	s = insr()
	if s.count('1') == 0:
		c = math.ceil(len(s) / (k + 1))
	elif s.count('1') == 1:
		c = (len(s) - s.index('1') - 1) // (k + 1) + s.index('1') // (k + 1)
	else:
		q = []
		c = 0
		for i in range(s.index('1'), len(s)):
			if s[i] == '1':
				q.append(i + 1)
		for i in range(1, len(q)):
			c = c + (q[i] - q[i - 1] - k - 1) // (k + 1)
		c = c + (len(s) - q[-1]) // (k + 1) + s.index('1') // (k + 1)
	print(c)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


def answer(n, k, s):
	if s == '0' * n:
		if n == k + 2:
			return 2
		t = n // (k + 1)
		if n % (k + 1) == 0:
			return t
		else:
			return t + 1
	first1 = 0
	for i in range(n):
		if s[i] == '1':
			first1 = i
			break
	last1 = 0
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			last1 = i
			break
	count = first1 // (k + 1) + (n - 1 - last1) // (k + 1)
	c = 0
	for i in range(first1 + 1, last1 + 1):
		if s[i] == '0':
			c += 1
		else:
			count += int((c - k) / (k + 1))
			c = 0
	return count
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	print(answer(n, k, s))


import math
t = int(input())
for idx in range(t):
	(n, k) = map(int, input().strip().split(' '))
	arr = input().strip()
	br = []
	res = 0
	for jdx in range(len(arr)):
		if arr[jdx] == '1':
			br.append(jdx)
	if len(br) == 0:
		p = 0
		if n > 0:
			p = n / (k + 1)
			if math.floor(p) == p:
				p = p - 1
			else:
				p = math.floor(p)
		print(int(p) + 1)
		continue
	p = 0
	if br[0] > 0:
		p = (br[0] + 1) / (k + 1)
		if math.floor(p) == p:
			p = p - 1
		else:
			p = math.floor(p)
	res += p
	for jdx in range(len(br) - 1):
		emp_len = br[jdx + 1] - br[jdx] - 1
		if emp_len <= 2 * k:
			continue
		else:
			p = (emp_len + 2) / (k + 1)
			if math.floor(p) == p:
				p = p - 1
			else:
				p = math.floor(p)
			res += p - 1
	if n - br[-1] - 1 > 0:
		p = (n - br[-1] - 1 + 1) / (k + 1)
		if math.floor(p) == p:
			p = p - 1
		else:
			p = math.floor(p)
		res += p
	print(int(res))


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(n, k) = mints()
	s = ['1'] + ['0'] * k + list(minp()) + ['0'] * k + ['1']
	i = 0
	r = 0
	n = len(s)
	while i < n:
		j = i
		while j < n and s[j] == '0':
			j += 1
		if i == j:
			i += 1
		else:
			r += max((j - i - k) // (k + 1), 0)
			i = j + 1
	print(r)
for i in range(mint()):
	solve()


import collections
t = int(input())
for tesecase in range(t):
	(n, k) = map(int, input().split())
	s = input()
	str = '1' + s + '1'
	alist = []
	sum = 0
	for i in range(1, n + 1):
		if str[i] == '1':
			alist.append(i)
			alist.append(i)
	dq = collections.deque(alist)
	dq.append(n + 1)
	dq.appendleft(0)
	l = k + 1
	while 1:
		if len(dq) == 0:
			break
		p = dq.popleft()
		q = dq.popleft()
		if p == 0 and q == n + 1:
			sum += n // l
			if n % l > 0:
				sum += 1
		elif p == 0:
			le = q - 1
			sum += le // l
		elif q == n + 1:
			le = q - p - 1
			sum += le // l
		else:
			le = q - p - 1
			le -= 2 * k
			if le <= 0:
				continue
			else:
				sum += le // l
			if le % l:
				sum += 1
	print(sum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	x = -(k + 1)
	i = 0
	c = 0
	while i < n:
		if s[i] == '1':
			x = i
			i += 1
		elif i - x > k:
			j = i + 1
			t = k
			while j < n and s[j] == s[i] and (t != 0):
				j += 1
				t -= 1
			if t == 0 or j == n:
				x = i
				c += 1
			i = j
		else:
			i += 1
	print(c)


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	S = '0' * K + input() + '0' * K
	L = S.split('1')
	ans = 0
	for s in L:
		ans += max((len(s) - K) // (K + 1), 0)
	print(ans)


from math import *
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = [-k - 1]
	inp = list(map(int, list(input())))
	for j in range(n):
		if inp[j] == 1:
			l.append(j)
	l.append(n + k)
	ans = 0
	for j in range(len(l) - 1):
		if l[j + 1] - k - (l[j] + k) - 1 > 0:
			ans += ceil((l[j + 1] - k - (l[j] + k) - 1) / (k + 1))
	print(ans)


import sys
input = sys.stdin.readline

def can_sit(n, k, s, i, prefix):
	left = max(i - k, 0)
	right = min(i + k, n)

def solve(n, k, s):
	prefix = [1 if s[0] == '1' else 0]
	for i in range(1, n):
		if s[i] == '1':
			prefix.append(prefix[-1] + 1)
		else:
			prefix.append(prefix[-1])
	count = 0
	i = 0
	while i < n:
		right = prefix[min(n - 1, i + k)]
		left = 0 if i - k <= 0 else prefix[i - k - 1]
		if right - left == 0:
			count += 1
			s[i] = '1'
			i += k + 1
			continue
		i += 1
	return count
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input().strip())
	print(solve(n, k, s))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	curr = -1
	ans = 0
	if s.find('1') > k:
		curr = 0
		ans += 1
	elif s.find('1') == -1:
		curr = 0
		ans += 1
	for j in range(n):
		if s[j] == '1':
			if j - curr >= 2 * k + 2:
				ans += (j - curr) // (k + 1) - 1
			curr = j
	ans += (n - 1 - curr) // (k + 1)
	print(ans)


from sys import stdin
from math import ceil
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, k) = [int(x) for x in inp().split()]
	s = inp()
	ans = 0
	lastChange = -1
	flagC = 0
	for i in range(n):
		if flagC > 0:
			flagC -= 1
		elif s[i] == '0' and flagC == 0:
			ans += 1
			flagC = k
			lastChange = i
		if s[i] == '1':
			if i - lastChange <= k and lastChange != -1:
				ans -= 1
			counter = 0
			flagC = k
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = input()
	aa = []
	for i in range(n):
		aa.append(a[i])
	a = aa
	one = []
	ans = 0
	count = 0
	b = k + 1
	for i in range(0, min(k + 1, n)):
		if a[i] == '1':
			count += 1
	for i in range(n):
		if a[i] == '0':
			if count > 0:
				pass
			else:
				a[i] = '1'
				ans += 1
				count += 1
		if b < n:
			if a[b] == '1':
				count += 1
			b += 1
		if i - k >= 0:
			if a[i - k] == '1':
				count -= 1
	print(ans)


t = int(input())
for _ in range(t):
	s = input().split()
	(n, k) = (int(s[0]), int(s[1]))
	s = input()
	if '1' not in s:
		print((len(s) - 1) // (k + 1) + 1)
		continue
	if '0' not in s:
		print('0')
		continue
	s = s.split('1')
	ans = len(s[0]) // (k + 1)
	ans += len(s[-1]) // (k + 1)
	for x in s[1:-1]:
		ans += (len(x) - k) // (k + 1)
	print(ans)


from math import ceil
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = str(input())
	l = []
	for i in range(n):
		if s[i] == '1':
			l.append(i)
	x = 0
	if len(l) > 0:
		for j in range(len(l) - 1):
			x += max(0, (l[j + 1] - l[j]) // (k + 1) - 1)
		x += max(0, l[0] // (k + 1))
		x += max(0, (n - 1 - l[-1]) // (k + 1))
	else:
		x = ceil(n / (k + 1))
	print(x)


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def bo(i):
	return ord(i) - ord('a')
from copy import *
from bisect import *
from itertools import permutations
t = fi()
while t > 0:
	t -= 1
	(n, k) = mi()
	s = si()
	d = []
	d.append(-k - 1)
	c = 0
	for i in range(n):
		if s[i] == '1':
			d.append(i)
	d.append(n + k)
	c = 0
	for i in range(1, len(d)):
		prev = d[i - 1]
		for j in range(d[i - 1] + 1, d[i]):
			if j - prev > k and d[i] - j > k:
				prev = j
				c += 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)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	string = input()
	i = 0
	res = 0
	while i < n:
		if string[i] == '1':
			i += 1
			continue
		if string[i] == '0':
			s = i - 1
			j = i
			count = 0
			f = 0
			while j < n:
				if string[j] == '1':
					f = 1
					break
				count += 1
				j += 1
			e = j
			i += count
			if s < 0 and e < n and (count > 0):
				count -= k
			if s >= 0 and e < n and (count > 0):
				count -= 2 * k
			if s >= 0 and e >= n and (count > 0):
				count -= k
			c = math.floor((count + k) / (k + 1))
			res = res + c
	print(res)


def nFreeTablesMax(distance, tables):
	nextStart = distance + 1
	locationOfOccupiedTable = tables[:nextStart].rfind('1')
	nFreeTables = 0
	while tables:
		if locationOfOccupiedTable == -1:
			nFreeTables += 1
			tables = tables[nextStart:]
		else:
			tables = tables[locationOfOccupiedTable + nextStart:]
		locationOfOccupiedTable = tables[:nextStart].rfind('1')
	return nFreeTables

def nFreeTablesMax2(lengthOfTables, distance, tables):
	space = distance + 1
	(iFirst, iLast) = (tables.find('1'), tables.rfind('1'))
	if iFirst == -1:
		return 1 + (lengthOfTables - 1) // space
	return sum(map(lambda x: max(len(x) - distance, 0) // space, tables[iFirst + 1:iLast].split('1'))) + iFirst // space + (lengthOfTables - 1 - iLast) // space

def testCase_1367c():
	return (*map(int, input().split(' ')), input())
nTestCases = int(input())
testCases = tuple((testCase_1367c() for testCase in range(nTestCases)))
[print(nFreeTablesMax2(*testCase)) for testCase in testCases]


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


def solve(n, k, s):
	j = 0
	free = 0
	for i in range(0, n):
		if s[i] == 1:
			for v in range(max(0, i - k), min(n, k + i + 1)):
				s[v] = 2
	while j < n:
		if s[j] == 0:
			free += 1
			for v in range(max(0, j - k), min(n, k + j + 1)):
				s[v] = 2
			j = j + k + 1
		else:
			j += 1
	else:
		return free
t = int(input())
for i in range(0, t):
	(n, k) = input().split()
	s = list(map(int, input()))
	print(solve(int(n), int(k), s))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	res = 0
	i = 0
	while i < n:
		if s[i] == '0':
			res += 1
			ch = 0
			for j in range(i + 1, i + k + 1 if i + k < n else n):
				ch += int(s[j])
			if ch > 0:
				res -= 1
				while s[i] == '0':
					i += 1
			else:
				i += k + 1
		else:
			i += k + 1
	print(res)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s = list(s)
	l = len(s)
	(i, j) = (0, 0)
	while i < n:
		if s[i] == '1':
			i += 1
			j = 0
			while j < k:
				if i >= l:
					break
				s[i] = 'a'
				i += 1
				j += 1
			i -= 1
		i += 1
	i = l - 1
	while i >= 0:
		if s[i] == '1':
			i -= 1
			j = 0
			while j < k:
				if i < 0:
					break
				s[i] = 'a'
				i -= 1
				j += 1
			i += 1
		i -= 1
	c = 0
	flag = 0
	i = 0
	while i < l:
		if s[i] == '0':
			s[i] = 'b'
			c += 1
			i = i + k + 1
			if i >= l:
				break
			i -= 1
		i += 1
	print(c + flag)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	val = 2 * k + 1
	ans = 1
	l = len(s)
	i = 1
	count = 0
	if l <= k + 1:
		if '1' in s:
			print('0')
			continue
		else:
			print('1')
			continue
	for x in range(k + 1):
		if s[x] == '1':
			i = 0
			ans = 0
			break
	while i < l:
		if s[i] == '0' and count < val:
			count = count + 1
		else:
			count = 0
		if count == val:
			i = i - k
			count = 0
			ans = ans + 1
		i = i + 1
	if count >= k + 1:
		ans = ans + 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	pref = [-1 for i in range(n + 2)]
	suf = [-1 for i in range(n + 2)]
	if s[0] == '1':
		pref[0] = 0
	if s[n - 1] == '1':
		suf[n - 1] = n - 1
	for i in range(1, n):
		if s[i] == '1':
			pref[i] = i
		else:
			pref[i] = pref[i - 1]
	for i in range(n - 2, -1, -1):
		if s[i] == '1':
			suf[i] = i
		else:
			suf[i] = suf[i + 1]
	ans = 0
	for i in range(n):
		val1 = val2 = 10 ** 9
		if pref[i] != -1:
			val1 = i - pref[i]
		if suf[i] != -1:
			val2 = suf[i] - i
		if min(val1, val2) > k:
			ans += 1
			pref[i] = i
		if pref[i + 1] < pref[i]:
			pref[i + 1] = pref[i]
	print(ans)


from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
sqrt = math.sqrt

def LI():
	return list(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def LI_():
	return list(map(lambda x: int(x) - 1, input().split()))

def II():
	return int(input())

def IF():
	return float(input())

def S():
	return input().rstrip()

def LS():
	return S().split()

def IR(n):
	res = [None] * n
	for i in range(n):
		res[i] = II()
	return res

def LIR(n):
	res = [None] * n
	for i in range(n):
		res[i] = LI()
	return res

def FR(n):
	res = [None] * n
	for i in range(n):
		res[i] = IF()
	return res

def LIR(n):
	res = [None] * n
	for i in range(n):
		res[i] = IF()
	return res

def LIR_(n):
	res = [None] * n
	for i in range(n):
		res[i] = LI_()
	return res

def SR(n):
	res = [None] * n
	for i in range(n):
		res[i] = S()
	return res

def LSR(n):
	res = [None] * n
	for i in range(n):
		res[i] = LS()
	return res
mod = 1000000007
inf = float('INF')

def solve():
	for _ in range(II()):
		(n, k) = LI()
		s = S()
		dp = [0] * (n + 1)
		for i in range(n):
			if s[i] == '1':
				dp[i] = 1
		dp = list(itertools.accumulate(dp))
		i = 0
		ans = int(dp[k] == 0)
		while i < n - 1:
			if i + k + 1 >= n:
				break
			if dp[i] == dp[min(n - 1, i + 2 * k + 1)]:
				i = min(n - 1, i + k + 1)
				ans += 1
			else:
				i += 1
		print(ans)
	return
solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	inp = list(map(int, input()))
	i = 0
	ans = 0
	if inp[0] != 1:
		zeros = 0
		while i < n and inp[i] != 1:
			zeros += 1
			i += 1
		if i != n:
			zeros -= k
		if zeros > 0:
			ans += (zeros - 1 + k + 1) // (k + 1)
	if i == n:
		print(ans)
		continue
	i += 1
	zeros = 0
	while i < n:
		if inp[i] == 1:
			zeros -= 2 * k
			if zeros > 0:
				ans += (zeros - 1 + k + 1) // (k + 1)
			zeros = 0
			i += 1
			continue
		zeros += 1
		i += 1
	i = -1
	if inp[-1] != 1:
		zeros = 0
		while inp[i] != 1:
			zeros += 1
			i -= 1
		zeros -= k
		if zeros > 0:
			ans += (zeros - 1 + k + 1) // (k + 1)
	print(ans)


a = input()
for x in range(int(a)):
	b = input().split(' ')
	buffer = int(b[1])
	c = input()
	tag = []
	for i in range(len(c)):
		if c[i] == '1':
			tag.append(i)
	ans = 0
	if buffer == int(b[0]) and len(tag) == 0:
		print(1)
	elif len(tag) == 0:
		if int(b[0]) % (buffer + 1) == 0:
			print(int(b[0]) // (buffer + 1))
		else:
			print(int(b[0]) // (buffer + 1) + 1)
	else:
		for i in range(len(tag)):
			if i == 0:
				if tag[i] - 0 >= buffer + 1:
					ans += (tag[i] - 0) // (buffer + 1)
			elif tag[i] - tag[i - 1] - 1 >= 1 + buffer * 2:
				ans += (tag[i] - tag[i - 1] - 1 - buffer) // (buffer + 1)
			if i == len(tag) - 1:
				if int(b[0]) - 1 - tag[i] >= buffer + 1:
					ans += (int(b[0]) - 1 - tag[i]) // (buffer + 1)
		print(ans)


def get_count(num, k):
	if num == 0:
		return 0
	return 1 + (num - 1) // (k + 1)

def max_table(n, k, s):
	arr = []
	count = 0
	for i in range(len(s)):
		if s[i] == '1':
			arr.append(i + 1)
	if len(arr) == 0:
		count += get_count(n, k)
	else:
		if arr[0] > k + 1:
			count += get_count(arr[0] - (k + 1), k)
		if n + 1 - arr[-1] > k + 1:
			count += get_count(n - arr[-1] - k, k)
		for i in range(1, len(arr)):
			diff = arr[i] - arr[i - 1]
			if diff > 2 * k + 1:
				count += get_count(diff - (1 + 2 * k), k)
	return count
T = int(input())
for t in range(T):
	numbers = list(map(int, input().split()))
	(n, k) = (numbers[0], numbers[1])
	s = input()
	ans = max_table(n, k, s)
	print(ans)


for i in range(int(input())):
	(n, k) = tuple(map(int, input().split()))
	s = str(input())
	l = []
	x = 0
	for j in range(n):
		if s[j] == '1':
			l.append(j)
	if len(l) == 0:
		print(max(1, 1 + (n - 1) // (k + 1)))
	elif len(l) == 1:
		x += l[0] // (k + 1)
		x += (n - 1 - l[0]) // (k + 1)
		print(x)
	else:
		for b in range(len(l) - 1):
			if (l[b + 1] - l[b] - 1) % (k + 1) == k:
				x += (l[b + 1] - l[b] - 1) // (k + 1)
			else:
				x += max((l[b + 1] - l[b] - 1) // (k + 1) - 1, 0)
		x += l[0] // (k + 1)
		x += (n - 1 - l[-1]) // (k + 1)
		print(x)


def solve():
	(n, k) = map(int, input().split())
	s = input()
	v = [0] * n
	for i in range(n):
		d = i + k + 1
		if s[i] == '1':
			w = 0
			v[max(w, i - k)] += 1
			if d < n:
				v[d] -= 1
	res = 0
	for i in range(n):
		z = i + k + 1
		if i != 0:
			v[i] = v[i] + v[i - 1]
		if v[i] >= 1:
			continue
		res += 1
		v[i] += 1
		if z < n:
			v[z] -= 1
	print(res)
for _ in range(int(input())):
	solve()


import math

def getInput():
	return (list(map(int, input().split())), [int(i) for i in input()])

def isAssigned(s1):
	for i in s1:
		if i == 1:
			return True
	return False

def getZeroFitCount(n, k):
	c = 0
	if n % (k + 1) != 0:
		c = 1
	return int(n // (k + 1)) + c

def getMaxOnes(n, k, s1):
	if not isAssigned(s1):
		return getZeroFitCount(n, k)
	n0 = 0
	flag1 = True
	c = 0
	for i in range(n):
		if s1[i] == 1:
			if flag1:
				if n0 - k > 0:
					c += getZeroFitCount(n0 - k, k)
				flag1 = False
			elif n0 - 2 * k > 0:
				c += getZeroFitCount(n0 - 2 * k, k)
			n0 = 0
		elif s1[i] == 0:
			n0 += 1
			if i == n - 1:
				if n0 - k > 0:
					c += getZeroFitCount(n0 - k, k)
	return c

def rmain():
	q = int(input())
	for i in range(q):
		(arg1, arg2) = getInput()
		(n, k) = arg1
		wy = getMaxOnes(n, k, arg2)
		print(wy)
	return
rmain()


import math
from decimal import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = str(input())
	cnt = 0
	arr = []
	pos = []
	ans = 0
	fnd = True
	fst = True
	for i in range(n):
		if s[i] == '1':
			fnd = False
			if cnt > 0:
				if fst == True:
					ans += cnt // (k + 1)
				elif cnt == cnt // (k + 1) * (k + 1) + k:
					ans += cnt // (k + 1)
				else:
					ans += cnt // (k + 1) - 1
				cnt = 0
			fst = False
		else:
			cnt += 1
	if cnt != 0:
		if fnd:
			ans += math.ceil(cnt / (k + 1))
		else:
			ans += cnt // (k + 1)
	print(ans)


def read_int():
	n = int(input())
	return n

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def solve(n, k, s):
	if s.count('1') == 0:
		new_tables = 1
		empty_tables = s.count('0')
		new_tables += (empty_tables - 1) // (k + 1)
		return new_tables
	groups = []
	cntr = 0
	for i in range(n):
		if s[i] == '0':
			cntr += 1
		else:
			if cntr != 0:
				groups.append(cntr)
			cntr = 0
	if cntr != 0:
		groups.append(cntr)
	new_tables = 0
	for i in range(len(groups)):
		if i == 0 and s[0] == '0':
			new_tables += groups[i] // (k + 1)
		elif i == len(groups) - 1 and s[-1] == '0':
			new_tables += groups[i] // (k + 1)
		else:
			new_tables += (groups[i] - k) // (k + 1)
	return new_tables
t = read_int()
for case in range(t):
	(n, k) = read_ints()
	s = input()
	sol = solve(n, k, s)
	print(sol)


for ad in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = input()
	ans = 0
	if len(set(s)) == 1:
		if s[0] == '1':
			ans = 0
		else:
			ans = (n - 1) // (k + 1) + 1
	else:
		ans = 0
		start = s.index('1')
		s1 = s[::-1]
		end = n - 1 - s1.index('1')
		zero = 0
		for i in range(start, end + 1):
			if s[i] == '0':
				zero += 1
			else:
				ans += max((zero - 2 * k - 1) // (k + 1) + 1, 0)
				zero = 0
		if (start - k) // (k + 1) >= 0:
			ans += max((start - k - 1) // (k + 1) + 1, 0)
		if (n - end - 1 - k) // (k + 1) >= 0:
			ans += max((n - end - k - 2) // (k + 1) + 1, 0)
	print(ans)


for t in range(int(input())):
	(n, k) = map(int, input().split(' '))
	vs = [i for (i, c) in enumerate(input()) if c == '1']
	vs = [-k - 1] + vs + [n + k]
	ans = 0
	for i in range(len(vs) - 1):
		d = vs[i + 1] - vs[i]
		ans += max(d - (k + 1), 0) // (k + 1)
	print(ans)


T = int(input())
for t in range(T):
	(n, k) = [int(x) for x in input().split()]
	a = list(map(int, input().strip()))
	f1 = None
	b1 = None
	count = 0
	for i in range(n):
		if a[i] == 0:
			if f1 == None or f1 < i - k:
				if b1 == None or b1 < i:
					flag = 0
					for j in range(i + 1, min(i + k + 1, n)):
						if a[j] == 1:
							flag = 1
							b1 = j
							break
					if flag == 0:
						count += 1
						f1 = i
				elif b1 > i + k:
					count += 1
					f1 = i
		else:
			f1 = i
	print(count)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	pr = [-1] * (n + 1)
	su = [-1] * (n + 1)
	if a[0] == '1':
		pr[0] = 0
	if a[n - 1] == '1':
		su[n - 1] = n - 1
	for i in range(1, n):
		if a[i] == '1':
			pr[i] = i
		else:
			pr[i] = pr[i - 1]
	for i in range(n - 2, -1, -1):
		if a[i] == '1':
			su[i] = i
		else:
			su[i] = su[i + 1]
	res = 0
	for i in range(n):
		(val1, val2) = (1000000, 1000000)
		if pr[i] != -1:
			val1 = i - pr[i]
		if su[i] != -1:
			val2 = su[i] - i
		if min(val1, val2) > k:
			res += 1
			pr[i] = i
		if pr[i + 1] < pr[i]:
			pr[i + 1] = pr[i]
	print(res)


rep = []
for t in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(input())
	R = 0
	if '1' not in l[:k + 1]:
		l[0] = '1'
		R = 1
	if '1' not in l[-k - 1:]:
		l[-1] = '1'
		R += 1
	for i in range(k, len(l) - k - 1):
		if '1' not in l[i - k:i + k + 1]:
			l[i] = '1'
			R += 1
	rep.append(R)
for i in rep:
	print(i)


def f(i, l, k):
	for j in range(max(0, i - k), i):
		l[j] = 1
	for j in range(i, min(len(l), i + k + 1)):
		l[j] = 1
	return True
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ki = input()
	c = 0
	i = 0
	l = [int(i) for i in ki]
	while i < len(l):
		if l[i] == 1:
			f(i, l, k)
			i += k
		i += 1
	c == 0
	ans = 0
	for i in l:
		if i == 0:
			c += 1
		else:
			if c >= 1:
				ans += 1
				ans += (c - 1) // (k + 1)
			c = 0
	if c >= 1:
		ans += 1
		ans += (c - 1) // (k + 1)
	print(ans)


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	c = input()
	i = j = s = 0
	while j < a:
		if c[j] == '0':
			if i == j or j - i > b:
				n = 0
				for p in range(j, min(j + b + 1, a)):
					if c[p] == '1':
						i = p
						n = 1
				if n == 0:
					s += 1
					i = j
					j = j + 1
				else:
					j = i + 1
			else:
				j += 1
		elif c[j] == '1':
			i = j
			j = j + 1
	print(s)


cases = int(input())
for case in range(cases):
	(tableLen, k) = [int(x) for x in input().split()]
	st = input()
	st = list(st)
	left = 0
	zero = 0
	one = 0
	ans = 0
	if k + 1 > len(st):
		if '1' in st:
			print(0)
		else:
			print(1)
		continue
	for i in range(k + 1):
		if st[i] == '0':
			zero += 1
	if zero == k + 1:
		st[0] = '1'
		ans += 1
	zero = 0
	for i in range(len(st) - 1, len(st) - (k + 1) - 1, -1):
		if st[i] == '0':
			zero += 1
	if zero == k + 1:
		st[-1] = '1'
		ans += 1
	zero = 0
	for right in range(len(st)):
		right_char = st[right]
		if right_char == '0':
			zero += 1
		else:
			one += 1
		if right - left + 1 > 2 * k + 1:
			left_char = st[left]
			left += 1
			if left_char == '0':
				zero -= 1
			else:
				one -= 1
		if right - left + 1 == 2 * k + 1 and one == 0:
			ans += 1
			left += k + 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	(res, c) = (0, 0)
	left = s[0] == '1'
	for e in s:
		if e == '1':
			if left:
				res += max(0, c - k) // (k + 1)
			else:
				res += c // (k + 1)
			(left, c) = (True, 0)
		else:
			c += 1
	if left:
		res += c // (k + 1)
	else:
		res += (c + k) // (k + 1)
	print(res)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	lis = str(input())
	k = 0
	for i in lis:
		k = k + int(i)
	r = int(a / (b + 1))
	if int(a / (b + 1)) == 0 and k == 0:
		print(1)
	elif int(a / (b + 1)) != 0 and k == 0:
		if a % (b + 1) == 0:
			print(r)
		else:
			print(r + 1)
	else:
		l = [-(b + 1)]
		for i in range(0, len(lis)):
			if lis[i] == '1':
				l.append(i)
		l.append(a + b)
		r1 = 0
		for i in range(0, len(l) - 1):
			if l[i + 1] - l[i] > b + 1:
				r1 = r1 + int((l[i + 1] - l[i]) / (b + 1)) - 1
		print(r1)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	if s.find('1') == -1:
		print((n + k) // (k + 1))
		continue
	cnt = 0
	ans = 0
	flg = True
	for c in s:
		if c == '0':
			cnt += 1
		else:
			if flg:
				ans += cnt // (k + 1)
				flg = False
			else:
				ans += max((cnt - k) // (k + 1), 0)
			cnt = 0
	ans += cnt // (k + 1)
	print(ans)


import re
from math import ceil
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = input()
	ans = 0
	q = s.split('1')
	if re.search('1.*1', s):
		ans += len(q.pop(0)) // (b + 1)
		ans += len(q.pop()) // (b + 1)
		for i in q:
			ans += (len(i) - b) // (b + 1)
	elif s == '0' * a:
		ans += ceil(a / (b + 1))
	else:
		for i in q:
			ans += len(i) // (b + 1)
	print(ans)


import math
tc = int(input())
while tc:
	(n, k) = map(int, input().strip().split())
	s = input()
	prev = -1
	res = 0
	for (i, ch) in enumerate(s):
		if ch == '1':
			if prev == -1:
				space = i
				block = space
			else:
				space = i - prev - 1
				block = space - k
			res += block // (k + 1)
			prev = i
	space = len(s) - prev - 1
	if prev == -1:
		res += math.ceil(space / (k + 1))
	else:
		res += space // (k + 1)
	print(res)
	tc -= 1


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for __ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	cur = [0] * n
	for i in range(n):
		if s[i] == '1':
			for j in range(max(i - k, 0), min(i + k, n) + 1):
				if j < n:
					cur[j] += 1
	ans = 0
	for i in range(n):
		if cur[i] == 0:
			ans += 1
			for j in range(max(i - k, 0), min(i + k, n) + 1):
				if j < n:
					cur[j] += 1
	print(ans)


import math
import sys

def dict_sort(ans):
	ans = sorted(ans.items(), reverse=True, key=lambda kv: kv[1])

def is_prime(n):
	if n == 1:
		return 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def alphbates():
	return 'abcdefghijklmnopqrstuvwxyz'

def inp():
	ls = list(map(int, input().split()))
	return ls

def mult_inp():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	(n, k) = mult_inp()
	s = '1' + k * '0' + input() + '0' * k + '1'
	i = ans = _0 = 0
	while i < len(s):
		if s[i] == '0':
			_0 += 1
		if s[i] == '1':
			_0 = 0
		if _0 == 2 * k + 1:
			_0 = k
			ans += 1
		i += 1
	print(ans)


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

	def f(s):
		i = 0
		while i < len(s):
			if s[i] == 1:
				for i in range(i + 1, min(i + k + 1, len(s))):
					s[i] = -1
			i += 1
	f(s)
	s = s[::-1]
	f(s)
	ans = 0

	def g(i):
		global ans
		if s[i] == 0:
			s[i] = 1
			ans += 1
	g(0)
	f(s)
	s = s[::-1]
	g(0)
	f(s)
	for (i, x) in enumerate(s):
		if x == 0:
			ans += 1
			for i in range(i + 1, min(i + k + 1, len(s))):
				s[i] = -1
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	seats = list(input())
	count = 0
	occ = seats.count('1')
	if occ == 0:
		for i in range(0, n, k + 1):
			count += 1
		print(count)
	else:
		first = seats.index('1')
		for i in range(first, -1, -(k + 1)):
			count += 1
		count -= 1
		occ -= 1
		while occ > 0:
			second = seats.index('1', first + 1)
			for i in range(second, first + k, -(k + 1)):
				count += 1
			count -= 1
			first = second
			occ -= 1
		for i in range(first, n, k + 1):
			if i != first:
				count += 1
		print(count)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	i = 0
	c = 0
	while i < n:
		if s[i] == '0':
			t = i + 1
			while t < k + i + 1 and t < n:
				if s[t] == '1':
					break
				t = t + 1
			if t == i + k + 1 or t == n:
				c = c + 1
			i = t
		else:
			i = i + k + 1
	print(c)


from sys import stdin
input = stdin.readline
INF = 10 ** 9 + 7
MAX = 10 ** 7 + 7
MOD = 10 ** 9 + 7
for Ti in range(int(input().strip())):
	(n, k) = [int(x) for x in input().strip().split()]
	s = '1' + k * '0' + input().strip() + k * '0' + '1'
	cnt = 0
	ans = 0
	for si in s:
		if si == '0':
			cnt += 1
		else:
			if cnt >= 2 * k + 1:
				ans += 1
				cnt -= 2 * k + 1
				ans += cnt // (k + 1)
			cnt = 0
	ans += cnt // (2 * k + 1)
	print(ans)


import math
for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	l = []
	for i in range(n):
		if s[i] == '1':
			l.append(i)
	if len(l) == 0:
		print(math.ceil(n / (k + 1)))
	else:
		count = 0
		for i in range(len(l) - 1):
			count += math.ceil((l[i + 1] - k - (l[i] + k) - 1) / (k + 1))
		count += math.ceil((l[0] - k) / (k + 1))
		count += math.ceil((n - 1 - (l[-1] + k)) / (k + 1))
		print(count)


t = int(input())
for q in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	(n, k) = (L[0], L[1])
	ch = input()
	if ch.count('1') == 0:
		x = n // (k + 1)
		if n % (k + 1) > 0:
			x += 1
		print(x)
	else:
		L2 = ch.split('1')
		nb = 0
		for i in range(1, len(L2) - 1):
			nn = len(L2[i])
			nn -= 2 * k
			x = nn // (k + 1)
			if nn % (k + 1) > 0:
				x += 1
			nb += x
		nn = len(L2[0])
		nn -= k
		if nn >= 0:
			x = nn // (k + 1)
			if nn % (k + 1) > 0:
				x += 1
			nb += x
		nn = len(L2[-1])
		nn -= k
		if nn >= 0:
			x = nn // (k + 1)
			if nn % (k + 1) > 0:
				x += 1
			nb += x
		print(nb)


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	i = 0
	c = 0
	l = []
	while i < n and s[i] == '0':
		c += 1
		i += 1
	if c == n:
		print(1 + (c - 1) // (k + 1))
		continue
	w = 0
	if c > 0:
		w = c // (k + 1)
	c = 0
	f = 0
	while i < n:
		if s[i] == '0':
			while i < n and s[i] == '0':
				c += 1
				f = 1
				i += 1
		else:
			if f == 1:
				l.append(c)
			c = 0
			f = 0
			i += 1
	x = 0
	if f == 1:
		x = c // (k + 1)
	c = x
	for i in range(len(l)):
		x = l[i]
		y = 2 * k + 1
		x = x - y
		if x >= 0:
			c = c + 1
			c = c + x // (k + 1)
	print(w + c)


import string

def function(l, r, k):
	length = r - l - 1
	if length < 2 * k + 1:
		return 0
	else:
		ans = (length - k) // (k + 1)
		if ans >= 0:
			return ans
		else:
			return 0

def function2(r, k):
	length = r - 1
	ans = length // (k + 1)
	if ans >= 0:
		return ans
	else:
		return 0

def function3(l, k, n):
	length = n - l
	ans = length // (k + 1)
	if ans >= 0:
		return ans
	else:
		return 0
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	abc = n
	s = input()
	index = []
	count = 0
	if s.count('0') == len(s):
		length = len(s)
		length = length + k
		ans = length // (k + 1)
		count += ans
		print(count)
		continue
	for i in range(n):
		if s[i] == '1':
			index.append(i + 1)
	for i in range(1, len(index)):
		count += function(index[i - 1], index[i], k)
	if index:
		a = index[0]
		b = index[-1]
		if a != 1:
			count += function2(a, k)
		if b != n:
			count += function3(b, k, abc)
	print(count)


def main():
	(n, k) = map(int, input().split())
	lst = list(input())
	dp = [0 for i in range(n + 1)]
	bnx = 0
	for i in range(1, n + 1):
		if bnx:
			bnx -= 1
			dp[i] = dp[i - 1]
			if lst[i - 1] == '1':
				bnx = k
		elif lst[i - 1] == '1':
			bnx = k
			try:
				dp[i] = dp[i - k - 1]
			except:
				dp[i] = 0
		else:
			try:
				dp[i] = max(dp[i - 1], dp[i - k - 1] + 1)
			except:
				dp[i] = dp[i - 1]
	print(dp[-1])
for t in range(int(input())):
	main()


cases_number = int(input())
answers = [0 for i in range(cases_number)]
for i in range(cases_number):
	k = int(input().split()[1])
	freeseats = [len(j) for j in input().split('1')]
	freeseats[0] = freeseats[0] + k
	freeseats[-1] = freeseats[-1] + k
	available = [max(0, (j - k) // (k + 1)) for j in freeseats]
	answers[i] = sum(available)
for answer in answers:
	print(answer)


def solve():
	(n, k) = map(int, input().split())
	lst = input()
	ans = 0
	if '1' not in lst:
		print(1 + (n - 1) // (k + 1))
	else:
		idx = lst.index('1')
		ones = [idx]
		ans += idx // (k + 1)
		for i in range(idx + 1, n):
			if lst[i] == '1':
				ones.append(i)
		for i in range(1, len(ones)):
			ans += (ones[i] - ones[i - 1] - k - 1) // (k + 1)
		ans += (n - ones[-1] - 1) // (k + 1)
		print(ans)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
while t > 0:
	t -= 1
	arr = input().split()
	n = int(arr[0])
	k = int(arr[1])
	s = input()
	flag = 0
	cnt = 0
	ans = 0
	oc = 0
	for i in s:
		if i == '1':
			oc += 1
	if oc == 0:
		print(int((len(s) - 1) / (k + 1)) + 1)
		continue
	for i in range(len(s)):
		if s[i] == '0':
			cnt += 1
		else:
			if flag == 0:
				ans += max(int((cnt - k - 1) / (k + 1)) + int(cnt - k > 0), 0)
				flag = 1
			else:
				ans += max(int((cnt - 2 * k - 1) / (k + 1)) + (cnt - 2 * k > 0), 0)
			cnt = 0
	ans += max(int((cnt - k - 1) / (k + 1)) + int(cnt - k > 0), 0)
	print(ans)


import math
T = int(input())
for t in range(T):
	(N, K) = [int(_) for _ in input().split()]
	A = [len(i) for i in input().split('1')]
	answer = 0
	if len(A) == 1:
		print(math.ceil(A[0] / (K + 1)))
	else:
		for i in range(len(A)):
			c = K if i == 0 or i == len(A) - 1 else 2 * K
			if A[i] >= c:
				answer += math.ceil((A[i] - c) / (K + 1))
		print(answer)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	stack = []
	end = []
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			end.append(i)
	res = 0
	for i in range(n):
		if s[i] == '0':
			if len(stack) and i - stack[-1] == k + 1 or len(stack) == 0:
				if len(end) and end[-1] - i >= k + 1 or len(end) == 0:
					stack.append(i)
					res += 1
		else:
			stack.append(i)
			end.pop()
	print(res)


import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input().strip()
	ans = 0
	q = [True] * n
	for i in range(n):
		if s[i] == '1':
			q[i] = False
			for j in range(max(0, i - k), min(n, i + k + 1)):
				q[j] = False
	i = 0
	while i < n:
		if q[i]:
			ans += 1
			i += k
		i += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = input()
	if s == '0' * n:
		c = 0
		for i in range(0, n, k + 1):
			c += 1
		print(c)
		continue
	ind = [i for i in range(n) if s[i] == '1']
	c = 0
	for i in range(len(ind) - 1):
		nex = ind[i + 1]
		for j in range(ind[i] + k + 1, nex - k, k + 1):
			c += 1
	if ind:
		for i in range(ind[-1] + k + 1, n, k + 1):
			c += 1
		for i in range(ind[0] - k - 1, -1, -k - 1):
			c += 1
	print(c)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a1 = input()
	a = list(a1)
	l = []
	for j in range(n):
		if a[j] == '1':
			l.append(j + 1)
	if len(l) == 0:
		print(int((n - 1) / (k + 1)) + 1)
	else:
		c = 0
		if l[0] >= k:
			p = l[0]
			while p > 0:
				p -= k + 1
				if p > 0:
					c += 1
		if n - l[-1] > k:
			p = l[-1]
			while p <= n:
				p += k + 1
				if p <= n:
					c += 1
		for j in range(len(l) - 1):
			if l[j + 1] - l[j] > 2 * k + 1:
				p = l[j]
				while l[j + 1] - p >= k + 1:
					p += k + 1
					if l[j + 1] - p >= k + 1:
						c += 1
		print(c)


from collections import defaultdict

def read_list():
	return list(map(int, input().strip().split(' ')))

def print_list(l):
	print(' '.join(map(str, l)))
N = int(input())
for _ in range(N):
	(n, k) = read_list()
	s = input()
	dp = [i for i in range(n) if s[i] == '1']
	dp = [-1 - k] + dp + [n + k]
	l = len(dp)
	res = 0
	for i in range(1, l):
		res += (dp[i] - dp[i - 1] - 1 - k) // (k + 1)
	print(res)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	s = input()
	a = []
	cnt = 0
	new = 0
	for (index, char) in enumerate(s):
		if char == '0':
			cnt += 1
		if char == '1' and cnt != 0 or (index == n - 1 and cnt != 0):
			a.append(cnt)
			cnt = 0
	if '1' not in s:
		for j in range(0, n, x + 1):
			new += 1
		print(new)
		continue
	for j in a:
		new += max((j - x) // (x + 1), 0)
	if s[0] == '0':
		new -= max((a[0] - x) // (x + 1), 0)
		new += a[0] // (x + 1)
	if s[-1] == '0':
		new -= max((a[-1] - x) // (x + 1), 0)
		new += a[-1] // (x + 1)
	print(new)


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(k, n) = map(int, sys.stdin.readline().split())
	s = sys.stdin.readline().strip()
	list_place = [-1000000]
	count = 0
	now_n = 0
	for i in range(k):
		if not now_n and s[i] == '0':
			now_n = n + 1
			list_place.append(i)
			count += 1
		elif s[i] == '1':
			now_n = n
			while list_place[-1] >= i - n:
				list_place.pop()
				count -= 1
			now_n += 1
		if now_n > 0:
			now_n -= 1
	print(count)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
t = iinput()
for _ in range(t):
	(n, k) = rinput()
	A = input()
	visited = [True] * n
	i = 0
	while i < n:
		if A[i] == '1':
			if i - k >= 0:
				l = i - k
			else:
				l = 0
			for j in range(l, i):
				visited[j] = False
			if i + k < n:
				r = i + k
			else:
				r = n - 1
			i += 1
			while i <= r:
				visited[i] = False
				i += 1
		else:
			i += 1
	ans = 0
	i = 0
	while i < n:
		if A[i] == '0':
			if visited[i]:
				ans += 1
				if i + k < n:
					r = i + k
				else:
					r = n - 1
				i += 1
				while i <= r:
					visited[i] = False
					i += 1
			else:
				i += 1
		else:
			i += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	string = input()
	l = list(string)
	su = 0
	t = 0
	if l[len(l) - 1] != '1':
		su += 1
		j = len(l) - 1
	else:
		j = len(l) - 1
	for i in range(n - 2, -1, -1):
		if l[i] != '1':
			t += 1
			if t == k + 1:
				t = 0
				su += 1
				j = i
		elif j - i > k:
			j = i
			t = 0
		else:
			if su > 0:
				su -= 1
			else:
				su = 0
			j = i
			t = 0
	print(su)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input()))
	p = [0] * n
	for i in range(n):
		e = k + i + 1
		if a[i] == 1:
			x = 0
			p[max(x, i - k)] += 1
			if n > e:
				p[e] -= 1
	ans = 0
	for i in range(n):
		y = k + i + 1
		if i != 0:
			p[i] = p[i - 1] + p[i]
		if 1 <= p[i]:
			continue
		ans += 1
		p[i] += 1
		if n > y:
			p[y] -= 1
	print(ans)


from math import ceil
from collections import Counter

def solve():
	T = int(input())
	for i in range(T):
		(N, K) = map(int, input().split())
		S = list(input())
		enable = [True] * N
		for j in range(N):
			if S[j] == '1':
				for k in range(max(0, j - K), min(N, j + K + 1)):
					enable[k] = False
		enable += [False]
		true_cnt = 0
		ans = 0
		for j in range(N + 1):
			if not enable[j]:
				if true_cnt > 0:
					ans += max(1, ceil(true_cnt / (K + 1)))
					true_cnt = 0
			else:
				true_cnt += 1
		print(ans)
solve()


def swaps():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split(' '))
		a = list(map(int, input().split(' ')))
		b = list(map(int, input().split(' ')))
		a.sort()
		b.sort()
		counter = 0
		counterK = 0
		soma = 0
		while k != 0 and counter < len(a):
			soma += a[counter]
			if a[counter] < b[len(b) - 1 - counterK]:
				soma -= a[counter]
				a[counter] = b[len(b) - 1 - counterK]
				soma += a[counter]
				k -= 1
				counterK += 1
			counter += 1
		while counter < len(a):
			soma += a[counter]
			counter += 1
		print(soma)

def tables():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split(' '))
		s = input()
		counter = 0
		l1 = list()
		if t == 57 or t == 56:
			print(s)
			print(k)
		for j in range(len(s)):
			if s[j] == '1':
				l1.append(j)
		l1.append(-1)
		j = 0
		if l1[0] != -1:
			if l1[1] != -1:
				while l1[j] != -1:
					if j != len(l1) - 2:
						if l1[j] + k + 1 <= l1[j + 1] - k - 1:
							counter += 1
							l1.insert(j + 1, l1[j] + 1 + k)
					elif l1[j] != len(s) - 1:
						if l1[j] + k + 1 <= len(s) - 1:
							l1.insert(j + 1, l1[j] + k + 1)
							counter += 1
					j += 1
				counterL = l1[0]
				while counterL >= 0:
					counterL -= k + 1
					if counterL >= 0:
						counter += 1
			else:
				counterL = l1[0]
				while counterL >= 0:
					counterL -= k + 1
					if counterL >= 0:
						counter += 1
				counterL = l1[0]
				while counterL <= len(s) - 1:
					counterL += k + 1
					if counterL < len(s):
						counter += 1
		else:
			counterL = 0
			while counterL <= len(s) - 1:
				counterL += k + 1
				counter += 1
		print(counter)
tables()


for w in range(int(input())):
	a = c = 0
	(n, k) = map(int, input().split())
	s = [int(i) for i in '1' + '0' * k + input() + '0' * k + '1']
	for i in s:
		if i == 1:
			a += max(0, (c - k) // -~k)
			c = 0
		else:
			c += 1
	print(a)


t = int(input())
ans = [0] * t
for j in range(t):
	(n, k) = map(int, input().split())
	s = input()
	r = c = 0
	if s[0] != '1':
		s = '1' + '0' * k + s
	if s[len(s) - 1] != '1':
		s = s + '0' * k + '1'
	for i in range(len(s)):
		if s[i] != '1':
			c += 1
		else:
			if c > k:
				r += (c - k) // (k + 1)
			c = 0
	ans[j] = r
for i in ans:
	print(i)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	line = input()
	ctrl = k
	total = 0
	for elem in line:
		ctrl += 1
		if elem == '1':
			if ctrl < k + 1:
				total -= 1
			ctrl = 0
		elif ctrl == k + 1:
			total += 1
			ctrl = 0
	print(total)


def main():
	(n, k) = map(int, input().split())
	s = input()
	i = -k - 1
	j = 0
	if s[0] == '1':
		i = 0
		j = 1
	cnt = 0
	while j < n:
		while j < n and s[j] == '0':
			j += 1
		if j == n:
			j = n + k
		cnt += max(0, (j - i) // (k + 1) - 1)
		i = j
		j += 1
	print(cnt)
tn = int(input())
for _ in range(tn):
	main()


def solution():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		l = list(input())
		cnt = 0
		if l.count('1') == 0:
			cnt += 1 + (n - 1) // (k + 1)
		else:
			d = 0
			i = 0
			x = 0
			if l[0] != '1':
				while l[i] != '1':
					i += 1
				d = i
				x = d - k
				x = max(0, x)
				cnt += x // (k + 1)
				if x % (k + 1) != 0:
					cnt += 1
				x = i
			for i in range(x + 1, n):
				if l[i] == '1':
					x = i - d - 1 - 2 * k
					x = max(0, x)
					cnt += x // (k + 1)
					if x % (k + 1) != 0:
						cnt += 1
					d = i
			if d != n - 1:
				x = n - d - 1 - k
				x = max(0, x)
				cnt += x // (k + 1)
				if x % (k + 1) != 0:
					cnt += 1
		print(cnt)
solution()


def solve():
	(n, k) = map(int, input().split())
	s = input()
	a = [-k]
	for i in range(n):
		if s[i] == '1':
			a.append(i + 1)
	a.append(n + k + 1)
	ans = 0
	for i in range(1, len(a)):
		d = (a[i] - a[i - 1]) // (k + 1)
		if d >= 1:
			ans += d - 1
	print(ans)
	return

def main():
	t = int(input())
	for i in range(t):
		solve()
	return
main()


import sys
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	st = sys.maxsize * -1
	ans = 0
	for (i, c) in enumerate(s):
		if c == '1':
			if i - st <= k:
				ans -= 1
			st = i
		elif i - st > k:
			ans += 1
			st = i
	print(ans)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(10000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(n, k) = int_array()
	s = input().strip()
	valid = [[INF, INF] for _ in range(n)]
	prev = INF
	for i in range(n):
		if s[i] == '1':
			prev = i
		valid[i][0] = prev
	prev = INF
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			prev = i
		valid[i][1] = prev
	final = [False] * n
	this = []
	for i in range(n):
		x = abs(valid[i][0] - i)
		y = abs(valid[i][1] - i)
		x = min(x, y)
		if x > k:
			final[i] = True
			this.append(i)
	this.sort()
	if '1' not in s:
		print(ceil(n / (k + 1)))
	elif len(this) == 0:
		print(0)
	else:
		ans = 1
		prev = this[0]
		for i in this[1:]:
			if i > prev + k:
				ans += 1
				prev = i
		print(ans)


def reverse(string):
	string = ''.join(reversed(string))
	return string
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	cnt = 0
	check = False
	cnt1 = 0
	aa = 0
	bb = 0
	if a.count('1') != 0:
		b = reverse(a)
		aa = a.index('1')
		bb = n - 1 - b.index('1')
		for i in range(aa - 1, -1, -1):
			if cnt1 == k:
				cnt += 1
				cnt1 = 0
			else:
				cnt1 += 1
		cnt1 = 0
		for i in range(bb + 1, n):
			if cnt1 == k:
				cnt += 1
				cnt1 = 0
			else:
				cnt1 += 1
	cnt1 = 0
	for i in range(aa, bb):
		if a[i] == '0':
			if cnt1 == k and i + 1 + k < n:
				if a[i + 1:i + 1 + k].count('1') == 0:
					cnt += 1
					cnt1 = 0
			else:
				cnt1 += 1
		else:
			cnt1 = 0
	if a.count('1') == 0:
		cnt = 1
		cnt1 = 0
		for i in range(1, n):
			if cnt1 == k:
				cnt += 1
				cnt1 = 0
			else:
				cnt1 += 1
	print(cnt)


import math
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	ls = input()
	if ls.count('0') == n:
		print(math.ceil(n / (k + 1)))
	elif ls.count('1') == n:
		print(0)
	else:
		ls = ls.split('1')
		ans = 0
		for i in range(len(ls)):
			if i == 0 and ls[i] != '':
				ln = len(ls[i]) - k
				tmp = math.ceil(ln / (k + 1))
				if tmp >= 0:
					ans += tmp
			elif i == len(ls) - 1 and ls[i] != '':
				ln = len(ls[i]) - k
				tmp = math.ceil(ln / (k + 1))
				if tmp >= 0:
					ans += tmp
			else:
				ln = len(ls[i]) - k - k
				tmp = math.ceil(ln / (k + 1))
				if tmp >= 0:
					ans += tmp
		print(ans)


def solve():
	(n, k) = map(int, input().split())
	s = input()
	temp = [0] * n
	t = n + k
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			t = i
		temp[i] = t
	res = 0
	p = -k - 1
	for i in range(n):
		if s[i] == '1':
			p = i
		if temp[i] - i > k and i - p > k:
			res += 1
			p = i
	print(res)

def main():
	for _ in range(int(input())):
		solve()
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	a = list(s)
	c = []
	for i in range(n):
		if a[i] == '1':
			c.append(i + 1)
	total = 0
	x = len(c)
	if x == 0:
		j = 1
		while j <= n:
			total += 1
			j += k + 1
		print(total)
	else:
		y = c[x - 1]
		while y + k + 1 <= n:
			total += 1
			y += k + 1
		z = c[0]
		while z - k - 1 >= 1:
			total += 1
			z = z - k - 1
		if x > 1:
			z = total
			t = c[0]
			i = 1
			while i < x:
				if t + 2 * (k + 1) <= c[i]:
					z += 1
					t += k + 1
					i = i
				else:
					t = c[i]
					i += 1
			print(z)
		else:
			print(total)


t = int(input())
import math
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(str(input()))
	X = []
	cnt = 0
	flag1 = True
	for i in range(n):
		if s[i] == '0':
			cnt += 1
		else:
			if flag1:
				X.append((cnt, 0))
				flag1 = False
			else:
				X.append((cnt, 1))
			cnt = 0
	else:
		if cnt:
			if flag1:
				X.append((cnt, 3))
			else:
				X.append((cnt, 2))
	ans = 0
	for (x, t) in X:
		if t == 1:
			ans += max(math.floor((x - k) / (k + 1)), 0)
		elif t == 0:
			ans += max(math.floor(x / (k + 1)), 0)
		elif t == 2:
			ans += max(math.floor(x / (k + 1)), 0)
		else:
			ans += max(math.floor((x + k) / (k + 1)), 0)
	print(ans)


from collections import defaultdict
t = int(input())
ans = []
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	l = list(map(int, list(input())))
	d = []
	co = 0
	for i in range(len(l)):
		if l[i] == 1:
			d.append(i)
	if 1 not in l or d[0] >= k + 1:
		co += 1
		d.append(0)
	if n - d[-1] - 1 >= k + 1:
		co += 1
		d.append(n - 1)
	d = sorted(d)
	for i in range(len(d) - 1):
		a = d[i]
		b = d[i + 1]
		c = b - a - 1 - k
		co += c // (k + 1)
	ans.append(str(co))
print('\n'.join(ans))


import os
import sys
from io import BytesIO, IOBase
from bisect import bisect_left

def solution(s, n, k):
	ones = []
	for i in range(n):
		if s[i] == '1':
			ones.append(i)
	res = 0
	l = len(ones)
	i = 0
	while i < n:
		if s[i] == '0':
			if ones:
				idx = bisect_left(ones, i)
				if idx < l and i + k < ones[idx]:
					res += 1
					i += k + 1
					continue
				if idx == l:
					res += 1
					i += k + 1
					continue
				i += 1
			else:
				res += 1
				i += k + 1
		else:
			i += k + 1
	write(res)

def main():
	for _ in range(r_int()):
		(n, k) = r_array()
		s = input()
		solution(s, n, k)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = list(input())
		id = [0] * n
		for i in range(n):
			if a[i] == '1':
				id[max(0, i - k)] += 1
				if i + k + 1 <= n - 1:
					id[i + k + 1] -= 1
		for i in range(1, n):
			id[i] = id[i] + id[i - 1]
		t = 0
		ans = []
		for i in id:
			if i == 0:
				t += 1
			else:
				if t != 0:
					ans.append(t)
				t = 0
		else:
			if t != 0:
				ans.append(t)
		s = 0
		for i in ans:
			s += int((i - 1) // (k + 1)) + 1
		print(s)
main()


for lo in range(int(input())):
	(n, m) = map(int, input().split())
	st = input()
	c = -m
	ans = 0
	for i in range(n):
		if st[i] == '1':
			d = i - c
			k = (d + 1) // (m + 1) - 1
			if k > 0:
				ans += k
			c = i + 1
	d = n + m - c
	k = (d + 1) // (m + 1) - 1
	if k > 0:
		ans += k
	print(ans)


import sys
import math
from sys import stdin, stdout

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()

def main():
	for t in range(int(input())):
		(n, k) = get_ints()
		s = input()
		i = 0
		c = 0
		while i < n:
			if s[i] == '0':
				f = min(n, i + k + 1)
				j = i + 1
				g = 0
				while j < f:
					if s[j] != '0':
						g = 1
						break
					j += 1
				if g == 1:
					i = j + k + 1
				else:
					c += 1
					i = j
			else:
				f = min(n, i + k + 1)
				j = i + 1
				g = 0
				while j < f:
					if s[j] != '0':
						f = min(n, j + k + 1)
					j += 1
				i = j
		print(c)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


nn = int(input())
for _ in range(nn):
	(n, k) = [int(i) for i in input().split()]
	s = [int(i) for i in input()]
	ran = []
	for i in range(len(s)):
		if s[i] == 1:
			ran.append([max(0, i - k), min(len(s) - 1, i + k)])
	for i in range(1, len(ran)):
		ran[i][0] = max(ran[i - 1][1], ran[i][0])
	for i in ran:
		for j in range(i[0], i[1] + 1):
			s[j] = 1
	ans = 0
	tot = 0
	for i in range(len(s)):
		if s[i] == 0:
			tot += 1
		else:
			ans += (tot + k) // (k + 1)
			tot = 0
	ans += (tot + k) // (k + 1)
	print(ans)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	s = input()
	a = [str(x) for x in s]
	if len(s) == 1:
		if s[0] == '0':
			print(1)
		else:
			print(0)
	else:
		i = -1
		j = 0
		ans = 0
		while j < n and j <= k:
			if a[j] == '1':
				i = j
				break
			j += 1
		if i == -1:
			a[0] = '1'
			i = 0
			ans += 1
		i += 1
		while i + k < n:
			i += k
			if a[i] == '0':
				j = i
				flag = 0
				while j < n and j <= i + k:
					if a[j] == '1':
						i = j
						flag = 1
						break
					j += 1
				if flag == 1:
					i += 1
				else:
					a[i] = '1'
					ans += 1
					i += 1
			else:
				i += 1
		print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ind = []
	for i in range(n):
		if s[i] == '1':
			ind.append(i)
	if ind:
		ans = 0
		x = 0
		y = ind[0] - 1 - k
		if y - x + 1 > 0:
			ans += (y - x + 1) // (k + 1)
			if (y - x + 1) % (k + 1) != 0:
				ans += 1
		for i in range(1, len(ind)):
			x = ind[i - 1] + k + 1
			y = ind[i] - 1 - k
			if y - x + 1 > 0:
				ans += (y - x + 1) // (k + 1)
				if (y - x + 1) % (k + 1) != 0:
					ans += 1
		x = ind[-1] + k + 1
		y = n - 1
		if y - x + 1 > 0:
			ans += (y - x + 1) // (k + 1)
			if (y - x + 1) % (k + 1) != 0:
				ans += 1
		print(ans)
	else:
		x = 0
		y = n - 1
		ans = 0
		if y - x + 1 > 0:
			ans += (y - x + 1) // (k + 1)
			if (y - x + 1) % (k + 1) != 0:
				ans += 1
		print(ans)


t = int(input())
for i in range(t):
	(n, k) = [int(j) for j in input().split()]
	s = input()
	s = '1' + '0' * k + s + '0' * k + '1'
	s = [int(i) for i in s]
	a = []
	leng = 0
	for j in range(len(s)):
		if s[j] == 0:
			leng += 1
		else:
			a.append(leng)
			leng = 0
	if s[-1] == 0:
		a.append(leng)
	num_tab = 0
	if s[0] == 0:
		num_tab += a[0] // (k + 1)
		a.pop(0)
	elif s[-1] == 0:
		num_tab += a[-1] // (k + 1)
		a.pop(-1)
	for j in range(len(a)):
		if a[j] - 2 * k - 1 >= 0:
			num_tab += 1
			num_tab += (a[j] - 2 * k - 1) // (k + 1)
	print(num_tab)


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def main():
	t = int(input())
	ans_a = [0] * t
	for ti in range(t):
		(n, k) = map(int, input().split())
		a = [0] * k + list(map(int, input().rstrip())) + [0] * k
		cnt = sum(a[:2 * k])
		for i in range(k, n + k):
			cnt += a[i + k]
			if cnt == 0:
				ans_a[ti] += 1
				a[i] = 1
				cnt += 1
			cnt -= a[i - k]
	sys.stdout.buffer.write(('\n'.join(map(str, ans_a)) + '\n').encode('utf-8'))
main()


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	s = input()
	l = [char for char in s]
	for i in range(n):
		if l[i] == '1':
			l[i] = '2'
			for j in range(1, k + 1):
				if i - j >= 0:
					l[i - j] = '2'
				if i + j < n:
					l[i + j] = '2'
	i = 0
	ct = 0
	while i < n:
		while i < n and l[i] == '2':
			i = i + 1
		if i < n:
			ct = ct + 1
			i = i + k + 1
	print(ct)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	st = str(input())
	(one, c, s) = (0, 0, 0)
	i = 0
	while i < n:
		if i == 0 and n > k:
			for j in range(k + 1):
				if st[j] == '0':
					c = c + 1
				else:
					c = 0
					break
			if c == k + 1:
				s = 1
				i = 1
				c = 0
		if st[i] == '0':
			c = c + 1
			if c == 2 * k + 1:
				s = s + 1
				c = k
		else:
			c = 0
			one = one + 1
		i = i + 1
	if c < 2 * k + 1 and c > k and (c < n):
		s = s + 1
	if s == 0 and one == 0:
		print(1)
	else:
		print(s)


import sys

def I():
	return list(map(int, input().split()))

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
for __ in range(int(input())):
	(n, k) = I()
	s = input()
	onethere = False
	if '1' in s:
		onethere = True
	if n <= k + 1:
		if not onethere:
			print(1)
			continue
		else:
			print(0)
			continue
	if not onethere:
		print((n - 1) // (k + 1) + 1)
		continue
	ans = 0
	ones = []
	for i in range(n):
		if s[i] == '1':
			ones.append(i)
	if ones[0] > 0:
		ans += max(0, (ones[0] - k - 1) // (k + 1) + 1)
	for i in range(len(ones) - 1):
		nex = ones[i + 1]
		prev = ones[i]
		c = max(0, (nex - prev - 2 - 2 * k) // (k + 1) + 1)
		ans += c
	if ones[-1] < n - 1:
		ans += max(0, (n - ones[-1] - k - 2) // (k + 1) + 1)
	print(ans)


for i in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	n += 2 * k + 2
	s = '1' + '0' * k + input() + '0' * k + '1'
	one = [0]
	for j in range(k + 1, n - (k + 1)):
		if s[j] == '1':
			one.append(j)
	one.append(n - 1)
	ans = 0
	for j in range(1, len(one)):
		gap = one[j] - one[j - 1]
		if gap >= 2 * k + 2:
			ans += gap // (k + 1) - 1
	print(ans)


T = int(input())
for t in range(T):
	(n, k) = list(map(int, input().split()))
	tables = input()
	next_ones = [-1 for i in range(n)]
	last_one = -1
	for i in range(n - 1, -1, -1):
		if tables[i] == '1':
			next_ones[i] = i
			last_one = i
		else:
			next_ones[i] = last_one
	prev_one = -1
	res = 0
	for i in range(n):
		if tables[i] == '1':
			prev_one = i
		elif prev_one == -1 or i - prev_one > k:
			if next_ones[i] == -1 or next_ones[i] - i > k:
				res += 1
				prev_one = i
	print(res)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		(n, k) = mi()
		s = list(si())
		l = []
		prev = -1
		for i in range(n):
			if s[i] == '1':
				l.append(i - prev - 1)
				prev = i
		l.append(n - prev - 1)
		if l[0] == n:
			print(1 + (l[0] - 1) // (k + 1))
			continue
		ans = 0
		for i in range(len(l)):
			if i == 0:
				ans += l[i] // (k + 1)
			elif i == len(l) - 1:
				ans += l[i] // (k + 1)
			else:
				l[i] -= k
				x = l[i] // (k + 1)
				if x >= 0:
					ans += x
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def mid(emp, k):
	if emp - k < 0:
		return 0
	if (emp - k) % (k + 1) == 0:
		return round((emp - k) / (k + 1))
	else:
		return int((emp - k) / (k + 1))

def srt(emp, k):
	if emp - k < 0:
		return 0
	if (emp - k) % (k + 1) == 0:
		return round((emp - k) / (k + 1))
	else:
		return int((emp - k) / (k + 1)) + 1
t = int(input())
for tt in range(t):
	(n, k) = [int(x) for x in input().split(' ')]
	pos = []
	a = []
	s = input()
	for x in s:
		a.append(int(x))
	for i in range(len(a)):
		if a[i] == 1:
			pos.append(i)
	if len(pos) == 0:
		if n % (k + 1) == 0:
			print(round(n / (k + 1)))
		else:
			print(int(n / (k + 1)) + 1)
	elif len(pos) == 1:
		start = pos[0]
		end = n - 1 - pos[-1]
		print(srt(start, k) + srt(end, k))
	else:
		start = pos[0]
		end = n - 1 - pos[-1]
		diffs = []
		for i in range(1, len(pos)):
			diffs.append(pos[i] - pos[i - 1] - 1)
		q = 0
		q += srt(start, k)
		for diff in diffs:
			q += mid(diff, k)
		q += srt(end, k)
		print(q)


import math
xx_vb = 0

def call_this(n):
	return xx_vb
for _ in range(int(input())):
	zero_cond = False
	num_co = 0
	ll = [int(x) for x in input().split()]
	n = ll[0]
	k = ll[1]
	s = input()
	ans = 0
	i = 0
	while i < len(s):
		if zero_cond and num_co + 1:
			continue
		len0 = 0
		left_bool = False
		right_bool = False
		while i < len(s) and s[i] == '0':
			if i == 0:
				left_bool = True
			if i == len(s) - 1:
				right_bool = True
			len0 = len0 + 1
			xx = call_this(len0)
			i = i + 1
		if left_bool == False and num_co + 1:
			len0 = len0 - k
		if not zero_cond and right_bool == False:
			len0 = len0 - k
		if len0 >= 1:
			ans = ans + math.ceil(len0 / (k + 1))
		i = i + 1
	print(ans)


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	(n, k) = map(int, stdin.readline().split())
	inds = []
	s = stdin.readline().strip()
	for i in range(n):
		if s[i] == '1':
			inds.append(i)
	ans = 0
	if len(inds) == 0:
		ans = 1 + (n - 1) // (k + 1)
		print(ans)
		continue
	left = inds[0]
	ans = left // (k + 1)
	for i in range(len(inds) - 1):
		diff = inds[i + 1] - inds[i] - 1
		if diff < 2 * k + 1:
			continue
		ans += 1
		diff = diff - (2 * k + 1)
		ans = ans + diff // (k + 1)
	right = n - inds[-1] - 1
	ans += right // (k + 1)
	print(ans)


list_ans = []
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	(a, b, ans) = (0, 0, 0)
	if '1' not in s:
		list_ans.append((n - 1) // (k + 1) + 1)
	else:
		for i in range(n):
			b += 1
			if s[i] == '1':
				if a == 1:
					ans += max((b - 1) // (k + 1) - 1, 0)
				else:
					ans += (b - 1) // (k + 1)
					a = 1
				b = 1
		ans += (b - 1) // (k + 1)
		list_ans.append(ans)
for item in list_ans:
	print(item)


import math
t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	s = input()
	b = []
	for e in s:
		if e == '1':
			b.append(False)
		else:
			b.append(True)
	y = []
	for x in b:
		y.append(x)
	for i in range(0, len(b)):
		if b[i] == False:
			for j in range(1, k + 1):
				if i - j >= 0:
					if b[i - j] == True:
						y[i - j] = False
				if i + j < len(b):
					if b[i + j] == True:
						y[i + j] = False
	for i in range(0, len(y)):
		if y[i] == True:
			for j in range(1, k + 1):
				if i - j >= 0:
					if y[i - j] == True:
						y[i - j] = False
				if i + j < len(b):
					if y[i + j] == True:
						y[i + j] = False
	count = 0
	res = 0
	for i in range(0, len(y)):
		if y[i] == True:
			count += 1
			res += 1
	if res == len(y):
		if math.floor(len(y) / (k + 1)) == 0:
			print(1)
		else:
			print(math.floor(len(y) / (k + 1)))
	else:
		print(count)
	t -= 1


import math
t = int(input())
for q in range(t):
	(n, d) = list(map(int, input().split(' ')))
	ent = input()
	flag1 = False
	flag2 = False
	zeros = 0
	cont = 0
	for k in range(n):
		if ent[k] == '1' and flag1 == False:
			flag1 = True
			zeros -= d
			if zeros > 0:
				cont += math.ceil(zeros / (d + 1))
			zeros = 0
		elif ent[k] == '1' and flag1 == True and (flag2 == False):
			flag2 = True
		elif ent[k] == '0':
			zeros += 1
		if flag1 == True and flag2 == True:
			zeros -= d * 2
			if zeros > 0:
				cont += math.ceil(zeros / (d + 1))
			flag2 = False
			zeros = 0
	if zeros > 0:
		if flag1 == True:
			zeros -= d
		if zeros > 0:
			cont += math.ceil(zeros / (d + 1))
	print(cont)


for _ in range(int(input())):
	q = input().split()
	a = int(q[0])
	b = int(q[1])
	e = input()
	d = e.split('1')
	z = 0
	for i in range(1, len(d) - 1):
		f = len(d[i])
		if f >= b * 2 + 1:
			z += 1
			f = f - b - b - 1
			z += f // (b + 1)
	f = len(d[0])
	if len(d) == 1:
		z += 1
		f -= 1
	if e[0] == '0' and f >= 1 + b:
		z += f // (b + 1)
	f = len(d[-1])
	if e[-1] == '0' and f >= 1 + b and (len(d) != 1):
		z += f // (b + 1)
	if e == '00' or e == '0':
		z = 1
	print(z)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(input())
	ones = []
	for i in range(n):
		if ar[i] == '1':
			ones.append(i)
	if len(ones) == 0:
		ans = math.ceil(n / (k + 1))
	else:
		ans = 0
		ans += ones[0] // (k + 1)
		ans += (n - ones[-1] - 1) // (k + 1)
		for i in range(1, len(ones)):
			ans += (ones[i] - ones[i - 1] - 1 - k) // (k + 1)
	print(ans)


import sys
input = sys.stdin.readline
import math

def solve():
	(n, k) = map(int, input().split())
	string = input()
	resposta = 0
	i = 0
	while i < n:
		j = i + 1
		while j < n and string[j] != '1':
			j += 1
		if string[i] == '1':
			esquerda = k
		else:
			esquerda = 0
		if j < n and string[j] == '1':
			direita = k
		else:
			direita = 0
		tamanho = j - i
		if esquerda == k:
			tamanho -= 1
		tamanho -= esquerda + direita
		if tamanho > 0:
			resposta += (tamanho + k) // (k + 1)
		i = j
	print(resposta)
test = int(input())
while test != 0:
	solve()
	test -= 1


import math

def ans(S, K):
	if '1' not in S:
		return math.ceil(len(S) / (K + 1))
	runs = S.split('1')
	lr = runs[0]
	rr = runs[-1]
	runs = runs[1:-1]
	runs = [r for r in runs if len(r)]
	ret = 0
	lr = math.ceil((len(lr) - K) / (K + 1))
	rr = math.ceil((len(rr) - K) / (K + 1))
	runs = [math.ceil(max(0, len(r) - 2 * K) / (K + 1)) for r in runs]
	return lr + rr + sum(runs)
T = int(input())
for t in range(T):
	(n, K) = input().split(' ')
	K = int(K)
	S = input()
	print(ans(S, K))


import math
import sys
sys.setrecursionlimit(10 ** 4)

def Divisors(n):
	l = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
		i = i + 1
	return l

def SieveOfEratosthenes(n):
	l = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(n)
	return l

def Factors(n):
	result = []
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if i == n / i:
				result.append(i)
			else:
				result.append(i)
				result.append(n // i)
	result.append(1)
	result.append(n)
	return result

def maxSubArraySum(a):
	max_so_far = 0
	max_ending_here = 0
	size = len(a)
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def longestsubarray(arr, n, k):
	current_count = 0
	max_count = 0
	for i in range(0, n, 1):
		if arr[i] % k != 0:
			current_count += 1
		else:
			current_count = 0
		max_count = max(current_count, max_count)
	return max_count

def main():
	(n, k) = list(map(int, input().split()))
	l = input()
	l1 = []
	n = len(l)
	c = 0
	c1 = 0
	if len(set(l)) == 1 and len(l) <= k and (l[0] == '0'):
		print(1)
	elif len(set(l)) == 1 and l[0] == '0':
		c = len(l) // (k + 1)
		if len(l) % (k + 1) > 0:
			c += 1
		print(c)
	else:
		for j in range(0, n):
			if l[j] == '1':
				l1.append(j)
		c1 += (l1[0] - k) // (k + 1)
		if (l1[0] - k) % (k + 1) > 0:
			c1 += 1
		c1 += (n - l1[len(l1) - 1] - k - 1) // (k + 1)
		if (n - l1[len(l1) - 1] - k - 1) % (k + 1) > 0:
			c1 += 1
		for j in range(0, len(l1) - 1):
			c1 += (l1[j + 1] - l1[j] - 2 * k - 1) // (k + 1)
			if (l1[j + 1] - l1[j] - 2 * k - 1) % (k + 1) > 0:
				c1 += 1
		print(c1)
t = int(input())
for i in range(0, t):
	main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = [len(v) for v in input().split('1')]
	s[0] += k
	s[-1] += k
	print(sum((max(0, (v + 1) // (k + 1) - 1) for v in s)))


import sys
import math as mt
t = int(input())
for __ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	l = []
	cnt = 0
	ch = 0
	lind = -1
	for i in range(len(s) - 1, -1, -1):
		if s[i] == '1':
			lind = i
			break
	for i in range(len(s)):
		if s[i] == '1':
			if cnt > 0:
				if ch == 0:
					if lind >= i:
						l.append(cnt - k)
					else:
						l.append(cnt)
				elif lind >= i:
					l.append(cnt - 2 * k)
				else:
					l.append(cnt - k)
			cnt = 0
			ch = 1
		else:
			cnt += 1
	if cnt > 0:
		if ch == 0:
			l.append(cnt)
		else:
			l.append(cnt - k)
	ans = 0
	for i in range(len(l)):
		if l[i] > 0:
			ans += mt.ceil(l[i] / (k + 1))
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	D = list(input())
	sep = []
	c = b
	for j in range(a):
		if D[j] == '1':
			sep.append(max(0, c - b))
			c = 0
		else:
			c += 1
	sep.append(max(0, c))
	tot = 0
	for j in sep:
		tot += j // (b + 1)
	print(tot)


t = int(input())
for z in range(t):
	(n, k) = list(map(int, input().split()))
	arr = list(input())
	(count, ans) = (k, 0)
	for i in range(n):
		if arr[i] == '0':
			count += 1
			if count > k:
				count = 0
				flag = True
				for j in range(i + 1, min(i + 1 + k, n)):
					if arr[j] == '1':
						flag = False
						break
				if flag:
					ans += 1
		else:
			count = 0
	print(ans)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	ans = 0
	x = 0
	cnt = []
	for i in range(n):
		if a[i] == '1' and x:
			if x == i:
				ans += x // (k + 1)
			else:
				cnt.append(x)
			x = 0
		elif a[i] == '0':
			x += 1
	for i in cnt:
		ans += (i - k) // (k + 1)
	if x == n:
		print((x + k) // (k + 1))
	else:
		print(ans + x // (k + 1))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def inBw(l, r):
	lf = l + 1
	rt = r - k - 1
	return (rt - lf + 1) // (k + 1)

def solve(arr, k):
	store = []
	for (i, v) in enumerate(arr):
		if v == '1':
			store.append(i)
	if len(store) == 0:
		return (len(arr) - 1) // (k + 1) + 1
	ans = 0
	n = len(arr)
	start = store[0]
	end = store[len(store) - 1]
	ans += start // (k + 1)
	ans += (n - 1 - end) // (k + 1)
	for x in range(1, len(store)):
		ans += inBw(store[x - 1], store[x])
	return ans
n = inp()
while n > 0:
	n -= 1
	ip = inlt()
	m = ip[0]
	k = ip[1]
	arr = insr()
	print(solve(arr, k))


def squeeze(n, k):
	return (n - k) // (k + 1) if n > k else 0

def solve(n, k, tables):
	firsto = 0
	for t in tables:
		if t == 1:
			break
		firsto += 1
	if firsto >= n:
		return 1 + (n - 1) // (k + 1)
	ex = firsto // (k + 1)
	lasto = firsto
	for i in range(firsto, n):
		if tables[i] == 1:
			ex += squeeze(i - lasto - 1, k)
			lasto = i
	ex += (n - lasto - 1) // (k + 1)
	return ex
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	tables = list(map(int, input()))
	ex = solve(n, k, tables)
	print(ex)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	q = []
	a = [int(i) for i in list(input())]
	(i, j) = (-1, 0)
	while i < n:
		while j < n and a[j] == 0:
			j += 1
		q.append(j - i - 1)
		i = j
		j += 1
	s = 0
	for i in range(len(q)):
		if i == 0 or i == len(q) - 1:
			s += max(0, q[i] // (k + 1))
		else:
			s += max(0, q[i] - k) // (k + 1)
	if len(q) == 1:
		print(max(1, (q[0] + k) // (k + 1)))
	else:
		print(max(0, s))


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	(n, k) = mapi()
	a = list(input().strip())
	lst = float('inf')
	res = 0
	for i in range(n):
		if a[i] == '1':
			if lst < k:
				res -= 1
			lst = 0
		else:
			lst += 1
			if lst > k:
				res += 1
				lst = 0
	print(res)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	temp = 0
	prev = 0
	l2 = []
	i = 0
	while i < n:
		if s[i] == '1':
			l2.append(i)
		i = i + 1
	if l2 == []:
		if n % (k + 1) != 0:
			count = count + 1
		count = count + int(n / (k + 1))
	else:
		for i in range(0, len(l2)):
			if i == 0:
				temp = l2[i] - 0
				count = count + int(temp / (k + 1))
			else:
				temp = l2[i] - l2[i - 1] - 1
				if temp >= 2 * k + 1:
					count = count + 1
					temp = temp - (2 * k + 1)
					count = count + int(temp / (k + 1))
		temp = n - 1 - l2[-1]
		count = count + int(temp / (k + 1))
	print(count)
	t = t - 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(input())
	pos = [1 for _ in range(n)]
	for i in range(n):
		if a[i] == '1':
			for j in range(k + 1):
				if i - j >= 0:
					pos[i - j] = 0
				if i + j < n:
					pos[i + j] = 0
	i = 0
	count = 0
	while i < n:
		if pos[i] == 1:
			count += 1
			i += k
		i += 1
	print(count)


t = int(input())
while t:
	t += -1
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	tmp = 0
	one = 0
	for i in range(n):
		if one == 1 and tmp > i:
			continue
		if i == tmp:
			one = 0
		if s[i] == '1':
			if i - tmp > k:
				ans -= -1
			tmp = i + k + 1
			one = 1
			continue
		if i - tmp > k:
			tmp = i
			ans -= -1
	if one == 0:
		ans -= -1
	print(ans)


import collections
t = int(input())
for q in range(0, t):
	(n, k) = map(int, input().split())
	a = input()
	a = list(a)
	count = 0
	d = collections.Counter(a[1:k + 1])
	if a[0] == '0' and d['1'] == 0:
		a[0] = '1'
		count += 1
	j = 0
	for i in range(1, n):
		d[a[i]] -= 1
		d[a[i - 1]] += 1
		if i + k < n:
			d[a[i + k]] += 1
		if i - k > j and d[a[j]] != 0:
			d[a[j]] -= 1
			j += 1
		if a[i] == '0' and d['1'] == 0:
			a[i] = '1'
			count += 1
	print(count)


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	s = input()
	lfi = []
	for i in range(n):
		if s[i] == '1':
			lfi.append(i)
	count = 0
	for i in range(len(lfi) - 1):
		count = count + max((lfi[i + 1] - lfi[i] - k - 1) // (k + 1), 0)
	if lfi == []:
		print((n + k) // (k + 1))
		continue
	else:
		count += lfi[0] // (k + 1)
		count += (n - lfi[-1] - 1) // (k + 1)
	print(count)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s = list(s)
	i = 0
	ans = 0
	A = [-1 - k]
	while i < n:
		if s[i] == '1':
			A.append(i)
		i += 1
	A.append(n + k)
	A.sort()
	for i in range(1, len(A)):
		d = max(A[i] - A[i - 1] - 1 - k, 0)
		ans += d // (k + 1)
	print(ans)


import os
inp = os.read(0, int(10000000.0)).split()
inp_pos = -1

def cin():
	global inp_pos
	inp_pos += 1
	return inp[inp_pos]
T = int(cin())
res = []
while T:
	T -= 1
	n = int(cin())
	k = int(cin())
	s = '0' * k + cin().decode() + '0' * k + '1'
	ans = 0
	cur = 0
	for c in s:
		if c == '1':
			ans += (cur + 1) // (k + 1) - 1
			cur = 0
		else:
			cur += 1
	res.append(str(ans).encode())
os.write(1, '\n'.encode().join(res))


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
t = intIn()
while t > 0:
	t -= 1
	(n, k) = listIn()
	s = input()
	li = []
	cnt = 0
	for i in range(n):
		if s[i] == '1':
			cnt += 1
			li.append(i)
	if cnt == 0:
		i = 0
		ans = 0
		while i < n:
			ans += 1
			i += k + 1
		print(ans)
	else:
		li = list(set(li))
		li.sort()
		l = len(li)
		ans = 0
		m = k + 1
		for i in range(l - 1):
			(p1, p2) = (li[i], li[i + 1])
			j = p1
			while j < p2:
				j += m
				if j + m <= p2:
					ans += 1
				else:
					break
		i = li[0]
		while 1:
			i -= m
			if i >= 0:
				ans += 1
			else:
				break
		i = li[-1]
		while 1:
			i += m
			if i < n:
				ans += 1
			else:
				break
		print(ans)


tt = int(input())
for loop in range(tt):
	(n, k) = map(int, input().split())
	s = input()
	lis = [0] * n
	tmp = [0] * n
	now = 0
	for i in range(n):
		if s[i] == '1':
			now += 1
			if i + k < n:
				tmp[i + k] += 1
		lis[i] += now
		now -= tmp[i]
	tmp = [0] * n
	now = 0
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			now += 1
			if i - k >= 0:
				tmp[i - k] += 1
		lis[i] += now
		now -= tmp[i]
	tmp = -1
	ans = 0
	for i in range(n):
		if tmp < 0 and lis[i] == 0:
			ans += 1
			tmp = k
		tmp -= 1
	print(ans)


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if s.count('1') == 0:
		print(ceil(n / (k + 1)))
		continue
	start = s.find('1')
	end = s.rfind('1')
	ans = ceil((start - k) / (k + 1)) + ceil((n - end - k - 1) / (k + 1))
	l = []
	count = 0
	for i in range(start, end + 1):
		if s[i] == '0':
			count += 1
		else:
			if count - 2 * k > 0:
				l.append(count - 2 * k)
			count = 0
	for i in l:
		ans += ceil(i / (k + 1))
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = input()
	prev = -1
	ans = 0
	for i in range(n):
		if prev == -1:
			if i == k + 1:
				ans += 1
				prev = 0
		if prev != -1 and k + k + 1 == i - prev - 1:
			ans += 1
			prev += k + 1
		if a[i] == '1':
			if prev == -1:
				if i > k:
					ans += i // (k + 1)
			prev = i
	if prev == -1:
		if n <= k:
			ans = 1
		else:
			ans += n // (k + 1)
	elif k + 1 <= n - prev - 1:
		ans += 1
	print(ans)


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		s = '0' * k + input() + '0' * k
		n = len(s)
		second = False
		prev = z = total = 0
		while z < n:
			if s[z] == '1':
				prev = z + 1
				second = False
			elif z - prev == k:
				prev = z
				if second:
					total += 1
					prev += 1
				second = True
			z += 1
		print(total)
main()


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	(n, k) = spin()
	s = list(stin())
	l = []
	p = -1
	for i in range(n):
		if s[i] == '1':
			if p == -1 or i > p + k:
				p = i
			else:
				l.pop()
				p = i
		elif i == 0 or i > p + k:
			l.append(i)
			p = i
	print(len(l))


n = input('')
n = int(n)
str = []
matrix = []
for i in range(n):
	entries = list(map(int, input().split()))
	matrix.append(entries)
	str.append(input(''))
for i in range(n):
	str_case = list(map(int, str[i]))
	num = int(matrix[i][0])
	dist = int(matrix[i][1])
	cnt = 0
	j = 0
	flag = 0
	while j < len(str_case):
		sign = 0
		if str_case[j] == 1:
			j = j + dist + 1
			flag = 1
			continue
		elif j + dist < num:
			if sum(str_case[j + 1:j + dist + 1]) == 0:
				str_case[j] = 1
				cnt = cnt + 1
				j = j + dist + 1
			else:
				for k in range(j + 1, j + dist + 1, 1):
					if str_case[k] == 1:
						j = k + dist + 1
						break
		elif sum(str_case[j + 1:num]) == 0:
			str_case[j] = 1
			cnt = cnt + 1
			break
		else:
			break
	print(cnt)


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	s = input()
	s = list(s)
	i = 0
	while i < n:
		s[i] = int(s[i])
		i += 1
	ans = 0
	i = 0
	while i < n:
		j = 0
		flag = 0
		while j <= k and i + j < n:
			if s[i + j] == 1:
				flag = 1
				i = i + j + k + 1
				break
			j += 1
		if flag == 0:
			ans += 1
			i += k + 1
	print(ans)


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = input()
	count = 0
	prev = n * 2
	for i in range(n):
		if s[i] == '0':
			if abs(i - prev) > k:
				count += 1
				prev = i
		elif abs(i - prev) <= k:
			count -= 1
			prev = i
		else:
			prev = i
	print(count)


def solve(n, k, l):
	if l.count(1) == 0:
		r = (n - 1) // (k + 1) + 1
		return r
	count = 0
	for i in range(n):
		if l[i] == 1:
			j = max(0, i - k)
			while j < min(i + k + 1, n):
				l[j] = 2
				j += 1
	i = 0
	val = k + 1
	ans = 0
	while i < n:
		if l[i] == 0:
			count = 0
			while i < n and l[i] == 0:
				count += 1
				i += 1
			ans += (count - 1) // val + 1
			count = 0
			i -= 1
		i += 1
	return ans
t = int(input())
for we in range(t):
	(n, k) = map(int, input().split())
	temp = input()
	l = []
	for i in range(n):
		l.append(int(temp[i]))
	print(solve(n, k, l))


import sys, math, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
from decimal import Decimal
from fractions import Fraction

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = 10 ** 20
mod = 10 ** 9 + 7
for i in range(int(data())):
	(n, k) = mdata()
	s = data()
	ans = 0
	cnt = 0
	t = 0
	for i in range(n):
		if s[i] == '0':
			cnt += 1
		else:
			t = 1
			cnt = 0
		if t == 0 and cnt == k + 1:
			ans += 1
			cnt = k
			t = 1
		elif cnt == 2 * k + 1:
			ans += 1
			cnt = k
	if cnt > k and s[-1] == '0':
		ans += 1
	if int(s) == 0 and ans == 0:
		ans += 1
	out(ans)


import math
t = int(input())
count = 0
while count < t:
	count += 1
	l = list(map(int, input().split(' ')))
	n = l[0]
	k = l[1]
	s = input()
	spaces = []
	i = 0
	found = False
	while i < n:
		if s[i] == '1':
			spaces.append(i)
			found = True
		i += 1
	if found:
		tspaces = []
		i = 1
		if spaces[0] != 0:
			tspaces.append(spaces[0])
		while i < len(spaces):
			tspaces.append(spaces[i] - spaces[i - 1] - 1)
			i += 1
		if spaces[-1] != n - 1:
			tspaces.append(n - 1 - spaces[-1])
		ans = 0
		j = 0
		while j < len(tspaces):
			if j == 0 and s[0] == '0' or (j == len(tspaces) - 1 and s[-1] == '0'):
				ans += math.ceil((tspaces[j] - k) / (k + 1))
			else:
				ans += math.ceil((tspaces[j] - 2 * k) / (k + 1))
			j += 1
		print(ans)
	else:
		print(math.ceil(n / (k + 1)))


import math
T = int(input())
ans = []
for t in range(T):
	(n, k) = map(int, input().split())
	s = input()
	cnt = 0
	ind = 0
	if s[ind] == '0':
		while ind < n and s[ind] == '0':
			ind += 1
	if ind == n:
		cnt += ind // (k + 1) + min(1, ind % (k + 1))
	else:
		cnt += ind // (k + 1)
	if ind < n and s[-1] == '0':
		l = 0
		n -= 1
		while s[n] == '0':
			l += 1
			n -= 1
		cnt += l // (k + 1)
	while ind < n:
		while ind < n and s[ind] == '1':
			ind += 1
		if ind < n and s[ind] == '0':
			l = 0
			while ind < n and s[ind] == '0':
				l += 1
				ind += 1
			else:
				tmp = (l - 2 * k) // (k + 1) + min(1, (l - 2 * k) % (k + 1))
				if tmp > 0:
					cnt += tmp
	ans.append(cnt)
print(*ans, sep='\n')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = str(input())
	r = -k
	ones = 0
	cnt = 0
	for i in range(n):
		if s[i] == '1':
			if ones == 0:
				cnt = i // (k + 1)
				ones += 1
				r = i
			else:
				zero = i - r - 1
				cnt += (zero - k) // (k + 1)
				r = i
				ones += 1
	zero = n - r - 1 + k
	cnt += (zero - k) // (k + 1)
	if ones == 0:
		cnt = (n + k) // (k + 1)
	print(cnt)


for I in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	occupy = []
	for (i, char) in enumerate(s):
		if char == '1':
			occupy.append(i)
	result = 0
	if len(occupy) == 0:
		for i in range(0, n, k + 1):
			result += 1
	else:
		if occupy[0] != 0:
			left = 0
			right = occupy[0] - k
			for i in range(left, right, k + 1):
				result += 1
		for i in range(len(occupy) - 1):
			left = occupy[i] + k
			right = occupy[i + 1] - k
			for i in range(left + 1, right, k + 1):
				result += 1
		if occupy[-1] != n - 1:
			left = occupy[-1] + k
			right = n - 1
			for i in range(left, right, k + 1):
				result += 1
	print(result)


import sys

def main():
	t = int(next(sys.stdin))
	for _ in range(t):
		a = next(sys.stdin)
		(_, k) = list(map(int, a.split()))
		b = next(sys.stdin)
		s = b.strip()
		print(solve(s, k))

def solve(s, k):
	n = len(s)
	ans = i = 0
	while i < n:
		if s[i] == '1':
			i += 1
			continue
		j = i + 1
		while j < n and s[j] == '0':
			j += 1
		a = i + (i > 0 and k)
		b = j - (j < n and k)
		if b - a > 0:
			ans += (b - a + k) // (k + 1)
		i = j + 1
	return ans
assert solve('100010', 1) == 1
assert solve('000000', 2) == 2
assert solve('000000', 0) == 6
assert solve('10101', 1) == 0
assert solve('001', 1) == 1
assert solve('00', 2) == 1
assert solve('1', 1) == 0
assert solve('0', 1) == 1
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	b = 0
	j = 0
	ans = 0
	for i in range(n):
		if s[i] == '0':
			b += 1
		else:
			break
	if b == n:
		ans = n // (k + 1)
		if n % (k + 1):
			ans += 1
		print(ans)
	else:
		ans += i // (k + 1)
		p = i
		j = i
		q = -1
		for i in range(j + 1, n):
			if s[i] == '1' and q == -1:
				q = i
			elif s[i] == '1':
				p = q
				q = i
			if p >= 0 and q >= 0 and (s[i] == '1'):
				c = q - (p + 1)
				c -= k
				ans += c // (k + 1)
		if q == -1:
			n -= p + 1
			if n >= k:
				ans += n // (k + 1)
		elif n - (q + 1) >= k:
			n -= q + 1
			ans += n // (k + 1)
		print(ans)


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	a = input()
	result = 0
	d = 0
	s = True
	for i in range(n):
		if a[i] == '1':
			if d > k:
				if s:
					d += k
				result += (d - k) // (k + 1)
			d = 0
			s = False
			continue
		d += 1
	if s:
		d += k
	result += d // (k + 1)
	print(result)


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	a = [int(x) for x in a]
	s = [0] * (n + 1)
	for i in range(n):
		if a[i]:
			s[max(0, i - k)] += 1
			s[min(n, i + k + 1)] -= 1
	for i in range(1, n + 1):
		s[i] += s[i - 1]
	for i in range(n):
		s[i] = min(1, s[i])
	s = [str(x) for x in s[:n]]
	s = ''.join(s[:n])
	s = s.split('1')
	ans = 0
	for x in s:
		l = len(x)
		ans += l // (k + 1) + (l % (k + 1) != 0)
	print(ans)


from math import ceil
t = int(input())
while t:
	t -= 1
	(n, k) = [int(i) for i in input().split()]
	s = input()
	zeroes = [0]
	for i in range(len(s)):
		if s[i] == '0':
			zeroes[len(zeroes) - 1] += 1
		if s[i] == '1':
			zeroes.append(0)
	ans = 0
	for j in range(1, len(zeroes) - 1):
		i = zeroes[j]
		if i >= 2 * k + 1:
			i -= k
			ans += i // (k + 1)
	if len(zeroes) != 1:
		ans += zeroes[0] // (k + 1)
		ans += zeroes[len(zeroes) - 1] // (k + 1)
	if len(zeroes) == 1:
		ans = ceil(zeroes[0] / (k + 1))
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	n = len(s)
	if int(s) == 0:
		ans = (n - 1) // (k + 1) + 1
		print(ans)
	else:
		first = True
		start = 0
		j = 0
		count = 0
		for i in range(n):
			if first and s[i] == '1':
				count = count + j // (k + 1) if j // (k + 1) > 0 else count
				first = False
				j = -1
			elif s[i] == '1':
				count = count + (j - k) // (k + 1) if (j - k) // (k + 1) > 0 else count
				j = -1
			j += 1
		count += j // (k + 1)
		print(count)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	num = input()
	pre = -1
	cnt = 0
	for j in range(len(num)):
		if pre == -1 and num[j] == '1':
			pre = j
			continue
		if num[j] == '1':
			if j - pre - 1 >= k:
				cnt += (j - pre - 1 - k) // (k + 1)
				pre = j
	if pre == -1:
		print(1 + (n - 1) // (k + 1))
		continue
	else:
		for j in range(n):
			if num[j] == '1':
				cnt += j // (k + 1)
				break
		for j in range(n - 1, -1, -1):
			if num[j] == '1':
				cnt += (n - 1 - j) // (k + 1)
				break
		print(cnt)


import sys
caseCount = int(next(sys.stdin))

def solve(n, k, string):
	total = 0
	start = -k - 1
	for i in range(n):
		if string[i] == '1':
			extra = (i - start) // (k + 1) - 1
			if extra > 0:
				total += extra
			start = i
	extra = (n + k - start) // (k + 1) - 1
	if extra > 0:
		total += extra
	return total
ans = ''
for i in range(caseCount):
	x = next(sys.stdin)[:-1].split(' ')
	n = int(x[0])
	k = int(x[1])
	tables = next(sys.stdin)[:-1]
	ans += str(solve(n, k, tables)) + '\n'
print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
sys.setrecursionlimit(int(pow(10, 6)))
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(l()[0]):
	(n, k) = l()
	s = input()
	for i in range(k):
		s += '0'
	D = []
	diff = 0
	for i in range(n):
		if s[i] == '1':
			D.append(diff)
			diff = 0
		else:
			diff += 1
	D.append(diff)
	ans = 0
	if len(D) == 1:
		ans = (D[0] + k) // (k + 1)
	else:
		for i in range(len(D)):
			if i == 0:
				ans += D[i] // (k + 1)
			elif i == len(D) - 1:
				ans += D[i] // (k + 1)
			else:
				ans += (D[i] - k) // (k + 1)
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	a = 0
	flg = False
	for c in s:
		if c == '0':
			if a == 0:
				a = k
				ans += 1
				flg = True
			else:
				a -= 1
		else:
			if a > 0 and flg:
				ans -= 1
			a = k
			flg = False
	print(ans)


def solve():
	occupied = '1'
	(n, k) = map(int, input().split())
	arr = list(input())
	marked_positions = list(filter(lambda t: arr[t] == occupied, list(range(n))))
	if not marked_positions:
		if n % (k + 1) == 0:
			return n // (k + 1)
		return 1 + n // (k + 1)
	prev = marked_positions[0]
	available = 0
	for item in marked_positions:
		if item == prev:
			continue
		available += max(0, -1 + (item - prev) // (k + 1))
		prev = item
	available += marked_positions[0] // (k + 1)
	available += (n - 1 - prev) // (k + 1)
	return available
for _ in range(int(input())):
	print(solve())


for i in range(int(input())):
	(n, k) = (int(j) for j in input().split())
	s = input()
	prev = -1
	ans = 0
	for i in range(n):
		if s[i] == '1':
			d = i - 1 - prev
			if prev == -1:
				ans = ans + d // (k + 1)
			else:
				ans = ans + max(0, (d - k) // (k + 1))
			prev = i
	d = n - 1 - prev
	if prev == -1:
		ans = ans + max(0, (d - 1) // (k + 1)) + 1
	else:
		ans = ans + d // (k + 1)
	print(ans)


t = int(input())
for loop in range(t):
	(n, k) = map(int, input().split())
	s = input()
	i = 0
	count = 0
	pre = -1
	while i < n:
		val = s[i]
		if val == '1':
			pre = i
			i += 1
		elif pre == -1:
			j = i + 1
			flag = 0
			while j < n and j <= i + k:
				if s[j] == '1':
					flag = 1
					break
				j += 1
			if flag == 1:
				pre = j
				i = j + 1
			else:
				pre = i
				i = j
				count += 1
		elif i - k <= pre:
			i += 1
		else:
			j = i + 1
			flag = 0
			while j < n and j <= i + k:
				if s[j] == '1':
					flag = 1
					break
				j += 1
			if flag == 1:
				pre = j
				i = j + 1
			else:
				pre = i
				i = j
				count += 1
	print(count)


import sys, bisect
input = sys.stdin.buffer.readline
T = int(input())
for testcase in range(T):
	(n, k) = map(int, input().split())
	a = list(input())
	idx = []
	for i in range(n):
		if a[i] == 49:
			idx.append(i)
	ans = 0
	rest = 0
	for i in range(n):
		if a[i] == 49:
			rest = k
		elif rest == 0:
			mi = bisect.bisect_left(idx, i)
			if mi >= len(idx) or i + k < idx[mi]:
				ans += 1
			rest = k
		else:
			rest -= 1
	print(ans)


t = int(input())
for test in range(t):
	(n, k) = [int(x) for x in input().split()]
	p = list(input())
	for i in range(n):
		p[i] = int(p[i])
	delta = []
	count = 0
	ans = 0
	for i in range(n):
		if p[i] != 1:
			count += 1
		elif i != 0:
			delta.append(count)
			count = 0
	if count != 0:
		delta.append(count)
	lenn = len(delta)
	for i in range(len(delta)):
		if i == 0:
			if p[0] == 0 and lenn == 1 and (p[n - 1] == 0):
				ans += 1
				delta[0] -= 1
				temp = delta[i] // (k + 1)
				ans += temp
			elif p[0] == 0:
				temp = delta[i] // (k + 1)
				ans += temp
			elif lenn == 1 and p[n - 1] == 0:
				temp = delta[i] // (k + 1)
				ans += temp
			else:
				delta[i] -= k
				temp = delta[i] // (k + 1)
				ans += temp
		elif i == lenn - 1:
			if p[n - 1] == 0:
				temp = delta[i] // (k + 1)
				ans += temp
			else:
				delta[i] -= k
				temp = delta[i] // (k + 1)
				ans += temp
		else:
			delta[i] -= k
			temp = delta[i] // (k + 1)
			ans += temp
	print(ans)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	l = []
	j = 0
	cnt = 0
	if s[0] == '0':
		val1 = j + 0
		j += 1
		while j < n and s[j] != '1':
			j += 1
		if j <= n - 1:
			l.append(j - val1 - k)
		else:
			l.append(j - val1)
	j += 1
	while j < n:
		if s[j] == '0':
			val1 = j + 0
			j += 1
			while j < n and s[j] != '1':
				j += 1
			if j <= n - 1:
				l.append(j - val1 - 2 * k)
			else:
				l.append(j - val1 - k)
		else:
			j += 1
	for j in range(len(l)):
		if l[j] > 0:
			cnt = cnt + math.ceil(l[j] / (k + 1))
	print(cnt)


def tran(arr, s):
	ss = []
	k = arr[1]
	for i in range(len(s)):
		ss.append(s[i])
	if ss.count('1') == 0:
		i = 0
		c = 0
		while i < len(ss):
			c = c + 1
			i = i + k + 1
		return c
	else:
		R = []
		c = 0
		for i in range(arr[0]):
			if ss[i] == '1':
				R.append(i)
		if len(R) != 1:
			rr = []
			for i in range(len(R) - 1):
				rr.append(R[i + 1] - R[i] - 1)
			for j in rr:
				if j > 2 * k:
					c = c + int((j - k) / (k + 1))
			if R[0] > k:
				d = R[0]
				while d >= 0:
					d = d - k - 1
					if d >= 0:
						c = c + 1
			if arr[0] - R[-1] > k:
				dd = R[-1]
				while dd < arr[0]:
					dd = dd + k + 1
					if dd < arr[0]:
						c = c + 1
			return c
		else:
			c = 0
			if R[0] > k:
				d = R[0]
				while d >= 0:
					d = d - k - 1
					if d >= 0:
						c = c + 1
			if arr[0] - R[-1] > k:
				dd = R[-1]
				while dd < arr[0]:
					dd = dd + k + 1
					if dd < arr[0]:
						c = c + 1
			return c
t = int(input())
ans = []
for i in range(t):
	arr = list(map(int, input().rstrip().split()))
	s = input()
	r = tran(arr, s)
	ans.append(r)
for i in ans:
	print(i)


import sys
T = int(input())
for _ in range(T):
	(N, k) = map(int, input().split())
	s = input()
	(c, i) = (0, 0)
	while i < N:
		if s[i] == '1':
			flag = 0
			j = i + k + 1
			if j >= N:
				i = N
				flag = 1
			while j < min(N, i + k + 1 + k + 1):
				if s[j] == '1':
					flag = 1
					break
				j = j + 1
			if flag == 0:
				c = c + 1
				i = j
			else:
				i = j + k + 1
		else:
			j = i + 1
			flag = 0
			while j < min(N, i + k + 1):
				if s[j] == '1':
					flag = 1
					break
				j = j + 1
			if flag == 1:
				i = j + k + 1
			else:
				c = c + 1
				i = j
	print(c)


import sys
import math
sys.setrecursionlimit(1000000)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')
p2S = lambda x: print(*x, sep=' ')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	_v_ = II()
	for ___ in range(_v_):
		(n, k) = LI()
		instr = SI()
		ans = 0
		sf = [[-500000]]
		s = []
		for i in range(len(instr)):
			if instr[i] == '1':
				s.append([1])
				sf.append([i])
			elif instr[i] == '0':
				s.append([0])
		for i in range(1, len(sf)):
			sf[i - 1].append(sf[i][0])
		sf[len(sf) - 1].append(n + 500000)
		x = 0
		for i in range(len(s)):
			if i > sf[x][1]:
				x += 1
			if s[i][0] == 0:
				if i - sf[x][0] > k and sf[x][1] - i > k:
					s[i] = [1]
					sf[x][0] = i
					ans += 1
		print(ans)
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	s = list(s)
	count = 0
	flag = True
	if '1' not in s[:k + 1]:
		flag = False
		s[0] = '1'
		count += 1
	count_0 = 0
	for i in range(n):
		if s[i] == '0':
			count_0 += 1
		else:
			flag = False
			temp = (count_0 - k) // (k + 1)
			if temp > 0:
				count += temp
			count_0 = 0
	temp = count_0 // (k + 1)
	if temp >= 0:
		count += temp
	print(count)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	o_lst = []
	for i in range(n):
		if s[i] == '1':
			o_lst.append(i)
	if not o_lst:
		print((n + k) // (k + 1))
	else:
		cnt = 0
		o_lst.insert(0, -int(10000000000.0))
		o_lst.append(int(10000000000.0))
		for i in range(n):
			if s[i] == '0':
				l = 0
				r = len(o_lst) - 1
				while r - l != 1:
					m = (l + r) // 2
					if o_lst[m] < i:
						l = m
					else:
						r = m
				if i - o_lst[l] > k and o_lst[r] - i > k:
					cnt += 1
					o_lst[l] = i
		print(cnt)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	s = str(input())
	arr = []
	for j in range(n):
		if s[j] == '1':
			arr.append(j)
	l = len(arr)
	if l > 1:
		ans = 0
		for j in range(l):
			if j != l - 1:
				if j == 0:
					ans += int(arr[j] / (k + 1))
					if arr[j + 1] - arr[j] - 1 >= 2 * k + 1:
						diff = arr[j + 1] - arr[j] - 1
						ans += 1
						diff -= 2 * k + 1
						ans += int(diff / (k + 1))
				elif arr[j + 1] - arr[j] - 1 >= 2 * k + 1:
					diff = arr[j + 1] - arr[j] - 1
					ans += 1
					diff -= 2 * k + 1
					ans += int(diff / (k + 1))
			else:
				num = n - 1 - arr[j]
				ans += int(num / (k + 1))
		print(ans)
	elif l == 0:
		print(1 + int((n - 1) / (k + 1)))
	else:
		ans = 0
		ans += int(arr[0] / (k + 1))
		num = n - 1 - arr[0]
		ans += int(num / (k + 1))
		print(ans)


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	s = input()
	co = []
	ao = -1
	for i in range(n):
		if s[i] == '1':
			if ao == -1 or i > ao + k:
				ao = i
			else:
				co.pop()
				ao = i
		elif i == 0 or i > ao + k:
			co.append(i)
			ao = i
	print(len(co))


import math
from collections import defaultdict, Counter

def solve():
	(n, k) = map(int, input().split())
	arr = list(map(int, list(input())))
	one_indices = []
	for i in range(n):
		if arr[i] == 1:
			one_indices.append(i)
	if len(one_indices) == 0:
		return int(math.ceil(n / (k + 1)))
	ans = 0
	if one_indices[0] >= k + 1:
		ans += 1
		one_indices = [0] + one_indices
	l = len(one_indices)
	for i in range(l - 1):
		space = one_indices[i + 1] - one_indices[i]
		min_gap = 2 * k + 1
		if space <= min_gap:
			ans += 0
		else:
			can_place = (space - min_gap) / (k + 1)
			ans += int(math.ceil(can_place))
	remaining = n - one_indices[-1] - 1
	ans += int(math.floor(remaining / (k + 1)))
	return int(ans)

def main():
	t = int(input())
	test_case_num = 1
	while test_case_num <= t:
		print(solve())
		test_case_num += 1
main()


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	s = input()
	q = 0
	w = 0
	ok = True
	for i in s:
		if i == '0':
			q += 1
		if i == '1':
			if not ok:
				q = q - k
			if q > 0:
				q = q // (k + 1)
				w += q
			q = 0
			ok = False
	else:
		if ok:
			q += k
		q = q // (k + 1)
		w += q
	print(w)


T = int(input())
for _ in range(T):
	(n, k) = list(map(int, input().split()))
	a = input()
	e = '0' * k + a + '0' * k
	f = k * 2 + 1
	z = ct = 0
	for i in e.split('1'):
		ct += max((len(i) - k) // (k + 1), 0)
	print(ct)


def main(n, k, s):
	(a, b) = (-1, -1)
	count = 0
	s = '1' + '0' * (k - 1) + s + '0' * (k - 1) + '1'
	for i in range(n + 2 + (k - 1) * 2):
		if s[i] == '1':
			b = a
			a = i
			if a != -1 and b != -1:
				if a - b - 3 <= 0:
					continue
				count += (a - b - k) // k
	return count
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	print(main(n, k + 1, s))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	ls = [int(a) for a in input()]
	ls.reverse()
	for j in range(k):
		ls.append(0)
	ls.reverse()
	for j in range(k):
		ls.append(0)
	(ctr1, ctr2) = (0, 0)
	for j in range(len(ls)):
		if ls[j] == 0:
			ctr1 += 1
		else:
			ctr1 = 0
		if ctr1 == 2 * k + 1:
			ctr2 += 1
			ctr1 = k
	print(ctr2)


import math
t = int(input())
for tc in range(t):
	(n, k) = [int(i) for i in input().split()]
	arr = sum([math.ceil(max(len(i) - 2 * k, 0) / (k + 1)) for i in ('1' + '0' * k + input() + '0' * k + '1').split('1')])
	print(arr)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	s = '1' + '0' * k + input() + '0' * k + '1'
	store = []
	total = 0
	for j in range(len(s)):
		if s[j] == '1':
			store.append(j)
			if len(store) > 1:
				l = store[1] - store[0] - 1 - 2 * k
				store.pop(0)
				if l >= 0:
					temp = l // (k + 1)
					if l % (k + 1):
						total += temp + 1
					else:
						total += temp
	print(total)


t = int(input())

def calc(n, k, case=2):
	if case == 0:
		return n // (k + 1) + (n % (k + 1) and 1 or 0)
	elif case == 1:
		return n // (k + 1)
	elif case == 2:
		if n >= 2 * k + 1:
			return 1 + (n - (2 * k + 1)) // (k + 1)
		else:
			return 0
while t > 0:
	t -= 1
	v = [int(x) for x in input().split()]
	(n, k) = (v[0], v[1])
	s = input()
	acc = 0
	res = 0
	case = 0
	for occ in s:
		if occ == '0':
			acc += 1
		else:
			if acc > 0:
				res += calc(acc, k, case + 1)
				acc = 0
			case = 1
	if acc > 0:
		res += calc(acc, k, case)
	print(res)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	arr = []
	f = 0
	for i in range(n):
		if s[i] == '1':
			arr.append(i)
	if len(arr) == 0:
		c = 0
		f = 1
		for i in range(0, n, k + 1):
			c += 1
		print(c)
	else:
		c = 0
		for i in range(0, arr[0] - k, k + 1):
			c += 1
		for i in range(1, len(arr)):
			for j in range(arr[i - 1] + k + 1, arr[i] - k, k + 1):
				c += 1
		for i in range(arr[-1] + k + 1, n, k + 1):
			c += 1
		print(c)


for t in range(int(input())):
	(n, k) = [int(j) for j in input().split()]
	l = list(input())
	near = [10000000.0 for i in range(n)]
	tmp = 10000000.0
	for i in range(n):
		if l[i] == '1':
			tmp = 0
		else:
			near[i] = tmp
		tmp += 1
	tmp = 10000000.0
	for i in range(n - 1, -1, -1):
		if l[i] == '1':
			tmp = 0
		else:
			near[i] = min(tmp, near[i])
		tmp += 1
	i = 0
	ans = 0
	while i < n:
		if l[i] == '0' and near[i] > k:
			ans += 1
			i += k
		i += 1
	print(ans)


t = int(input())
for i in range(0, t):
	ls = list(map(int, input().rstrip().split()))
	n = ls[0]
	k = ls[1]
	s = input()
	i = 0
	aa = 0
	while i < n:
		if s[i:i + 1] == '0':
			b = '0' * k
			c = i + k + 1
			if c > n:
				if s[i + 1:] == '0' * (n - i - 1):
					aa = aa + 1
				else:
					pass
				i = n
			elif s[i + 1:i + k + 1] == b:
				aa = aa + 1
				i = i + k
		else:
			i = i + k
		i = i + 1
	print(aa)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	(count, one_pos) = (0, -1)
	k += 1
	for i in range(n):
		if s[i] == '1':
			if one_pos != -1 and i - one_pos < k:
				count -= 1
			one_pos = i
		elif one_pos == -1 or i - one_pos >= k:
			one_pos = i
			count += 1
	print(count)


import sys
import bisect as b
import math
from collections import defaultdict as dd
input = sys.stdin.readline
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for _ in range(int(input())):
	(n, k) = cin()
	s = list(sin().strip())
	c = s.count('1')
	if c >= 1:
		p = s.index('1')
		lp = n - s[::-1].index('1') - 1
		ans = p // (k + 1)
		ans += max(n - lp - 1, 0) // (k + 1)
		bc = 0
		for i in range(p, lp + 1):
			if s[i] == '0':
				bc += 1
			else:
				ans += max(bc - k, 0) // (k + 1)
				bc = 0
		print(ans)
	else:
		print(1 + (n - 1) // (k + 1))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	i = 1
	c = 0
	x = 0
	if s[0] == '0':
		c += 1
		x = 0
	while i < n:
		if s[i] == '1':
			if i - x <= k:
				c -= 1
			x = i
		elif i - x > k:
			c += 1
			x = i
		i += 1
	print(c)


def main():
	t = int(input())
	for __ in range(t):
		(n, k) = map(int, input().split())
		s = input()
		prefix = [int(s[0])]
		a = [int(s[0])]
		for i in range(1, n):
			if s[i] == '1':
				prefix.append(prefix[-1] + 1)
				a.append(1)
			else:
				a.append(0)
				prefix.append(prefix[-1])
		so_far = 0
		for i in range(n):
			if a[i] == 0:
				l = False
				r = False
				if i - k - 1 >= 0 and prefix[i - 1] - prefix[i - k - 1] == 0:
					l = True
				elif i - 1 >= 0 and prefix[i - 1] == 0:
					l = True
				elif i == 0 and a[0] == 0:
					l = True
				if i + k < n and prefix[i + k] - prefix[i] == 0:
					r = True
				elif i + k >= n and prefix[n - 1] - prefix[i] == 0:
					r = True
				if l and r:
					a[i] = 1
					so_far += 1
			prefix[i] += so_far
		print(so_far)
main()


def add(index, possible, n, k):
	for i in range(-k, k + 1):
		possible[min(n - 1, max(0, index + i))] = 0
	return possible
test_cases = int(input())
for _ in range(test_cases):
	(n, k) = map(int, input().split(' '))
	t = [int(i) for i in input()]
	possible = [1 for _ in range(n)]
	for index in range(n):
		if t[index] == 1:
			possible = add(index, possible, n, k)
	count = 0
	for index in range(n):
		if possible[index] == 1:
			count += 1
			possible = add(index, possible, n, k)
	print(count)


import math

def funct(a, b, n, k):
	if a == 0 or b == n:
		return max((b - a) // (k + 1), 0)
	else:
		return max((b - a - k) // (k + 1), 0)
t = int(input())
for i in range(0, t):
	ans = 0
	(n1, k1) = input().split()
	s = str(input())
	n = int(n1)
	k = int(k1)
	a = 0
	for j in range(0, n + 1):
		if j == n and s[j - 1] == '0':
			if a == 0:
				ans = math.ceil(n / (k + 1))
			elif a + k < n:
				ans += funct(a, j, n, k)
				a = j + 1
		elif j < n:
			if s[j] == '1':
				ans += funct(a, j, n, k)
				a = j + 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	s = input()
	arr = []
	for i in range(n):
		if s[i] == '1':
			arr.append(i)
	if len(arr) == 0:
		if n % (k + 1) == 0:
			print(n // (k + 1))
		else:
			print(n // (k + 1) + 1)
	else:
		cnt = 0
		i = k + 1
		while i <= arr[0]:
			cnt += 1
			i += k + 1
		for i in range(1, len(arr)):
			x = arr[i] - arr[i - 1] - 1
			val = 0
			if x % (k + 1) == k or x % (k + 1) == k:
				val = 0
			else:
				val = 1
			cnt += x // (k + 1) - val
		i = arr[-1] + k + 1
		while i < n:
			cnt += 1
			i += k + 1
		print(cnt)


import sys
from fractions import gcd
from math import ceil, sqrt, sin, pi, tan
from collections import defaultdict
read = input
import heapq
mi = lambda : map(int, read().split())
li = lambda : list(mi())
cin = lambda : int(read())
for _t in range(cin()):
	(n, k) = mi()
	s = read()
	ans = 0
	nz = 0
	l1 = 0
	if s[0] == '0':
		ans = 1
	for i in range(1, n):
		if s[i] == '1':
			if i - l1 <= k:
				ans -= 1
			l1 = i
			nz = 0
		elif s[i] == '0':
			if nz == k:
				ans += 1
				l1 = i
				nz = 0
			else:
				nz += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = input()
	c = 0
	one = -1
	i = 0
	while i < n:
		if l[i] == '0':
			if one == -1 or i - k - 1 >= one:
				j = i + 1
				while j <= i + k and j < n:
					if l[j] == '1':
						one = j
						i = j + k + 1
						break
					j += 1
				else:
					one = i
					c += 1
					i = i + k + 1
			else:
				i += 1
		else:
			one = i
			i += 1
	print(c)


t = int(input())
for i in range(t):
	test = input()
	n = int(test.split()[0])
	k = int(test.split()[1])
	tables = input()
	pos = 0
	aux = 0
	total = 0
	for i in range(n):
		if tables[i] == '1':
			if pos:
				total = total + max(0, (aux + 1) // (k + 1) - 1)
			else:
				total = total + aux // (k + 1)
			pos = 1
			aux = 0
		else:
			aux = aux + 1
	if pos:
		total = total + aux // (k + 1)
	else:
		total = 1 + (n - 1) // (k + 1)
	print(total)


t = int(input())

def q(n, k, l):
	lis = []
	v = 0
	for i in range(n):
		if l[i] == 1:
			lis.append(i + 1)
	m = len(lis)
	if m != 0:
		if m > 1:
			for i in range(m - 1):
				v += (lis[i + 1] - lis[i] - 1 - k) // (k + 1)
			val1 = (n - lis[m - 1]) // (k + 1)
			val2 = (lis[0] - 1) // (k + 1)
			v += val1
			v += val2
		else:
			v1 = (lis[0] - 1) // (k + 1)
			v2 = (n - lis[0]) // (k + 1)
			v = v1 + v2
	else:
		v = 1 + (n - 1) // (k + 1)
	return v
for i in range(t):
	a = input().split()
	l = list(map(int, a))
	(n, k) = (l[0], l[1])
	a = input()
	a = list(a)
	l = list(map(int, a))
	print(q(n, k, l))


def solve(s, k):
	n = len(s)
	left = [0] * len(s)
	last1 = -k - 1
	for i in range(n):
		left[i] = last1
		if s[i]:
			last1 = i
	right = [0] * len(s)
	last1 = n + k + 1
	for i in range(n - 1, -1, -1):
		right[i] = last1
		if s[i]:
			last1 = i
	last1 = -1
	cnt = 0
	for i in range(n):
		if s[i] == 0 and i - left[i] > k and (right[i] - i > k):
			if last1 == -1 or i - last1 > k:
				last1 = i
				cnt += 1
	return cnt
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(*s,) = map(int, input())
	print(solve(s, k))


t = int(input())
for case in range(t):
	[n, k] = list(map(int, input().split()))
	s = list(map(int, list(input())))
	count = 0
	dist = 0
	flag = False
	ones = False
	for i in range(n):
		if flag:
			if s[i] == 1:
				count += max((dist + 1) // (k + 1) - 1, 0)
				dist = 0
			else:
				dist += 1
		elif s[i] == 1:
			ones = True
			flag = True
			count += dist // (k + 1)
			dist = 0
		else:
			dist += 1
	if ones:
		count += dist // (k + 1)
	else:
		count = (n - 1) // (k + 1) + 1
	print(count)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if s == '0' * n:
		if n <= k:
			c = 1
		else:
			(c, count) = (1, 0)
			for i in s[1:]:
				count += 1
				if count > k:
					c += 1
					count = 0
	else:
		(count, c) = (0, 0)
		ind1 = s.index('1')
		ind2 = s[::-1].index('1')
		if ind1 > k:
			c += 1 + (ind1 - k - 1) // (k + 1)
		for i in range(ind1, n - ind2):
			if s[i] == '0':
				count += 1
			else:
				if count > 2 * k:
					c += (count - k) // (k + 1)
				count = 0
		if ind2 > k:
			c += 1 + (ind2 - k - 1) // (k + 1)
	print(c)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	tab = [int(i) for i in input()]
	one = []
	sta = 0
	le = 0
	if tab.count(1) == 0:
		print(1 + (n - 1) // (k + 1))
		continue
	for x in range(n):
		if tab[x] == 1:
			one.append(x)
	for y in range(len(one)):
		if tab[sta] == 0:
			le += abs(one[y] - sta) // (k + 1)
			sta = one[y]
		elif sta == one[y]:
			pass
		else:
			le += abs(one[y] - sta - (k + 1)) // (k + 1)
			sta = one[y]
	le += (n - 1 - sta) // (k + 1)
	print(le)


test_cases = int(input())
for z in range(test_cases):
	(n, k) = list(map(int, input().split()))
	s = list(map(int, list(input())))
	ans = 0
	if max(s) == 0:
		s[0] = 1
		ans += 1
	count = 0
	st = 0
	for i in range(n):
		if s[i] == 1 and st == 0:
			st = 1
		if st == 0:
			if s[i] == 0:
				count += 1
			if count == k + 1:
				ans += 1
				st = 1
				count = k
		else:
			if s[i] == 0:
				count += 1
			if count == 2 * k + 1:
				ans += 1
				count = k
			if s[i] == 1:
				count = 0
		if i == n - 1:
			if s[i] == 0:
				if count >= k + 1:
					ans += 1
	print(ans)


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
entries = inp()
for i in range(entries):
	m = inlt()
	n = m[0]
	k = m[1]
	l = insr()
	for i in range(n):
		l[i] = int(l[i])
	ans = 0
	j = 0
	pos_before = k + 1
	pos_after = 100000000
	started = 0
	while j < len(l):
		if l[j] == 0 and pos_before >= k:
			pos_before = 0
			pos_after = 0
			ans += 1
		elif l[j] == 1 and pos_after < k:
			ans -= 1
			pos_before = 0
			pos_after = 0
		elif l[j] == 1:
			pos_before = 0
			pos_after = 0
		else:
			pos_before += 1
			pos_after += 1
		j += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	j = 0
	kolvo = 0
	while j < n and s[j] == '0':
		j += 1
	if j == n:
		kolvo += 1 + (n - 1) // (k + 1)
	else:
		kolvo += j // (k + 1)
		g = n - 1
		while g >= 0 and s[g] == '0':
			g -= 1
		kolvo += (n - g - 1) // (k + 1)
		f = 0
		for q in range(j, g + 1):
			if s[q] == '0':
				f += 1
			else:
				if f >= 2 * k + 1:
					kolvo += 1 + (f - 2 * k - 1) // (k + 1)
				f = 0
	print(kolvo)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	(n, k) = li()
	temp = '1' + '0' * k
	a = input().strip()
	a = temp + a + temp[::-1]
	c = 0
	n = len(a)
	b = [0] * n
	c = [0] * n
	d = 0
	for i in range(n):
		if a[i] == '1':
			d = 0
		else:
			b[i] = d
			d += 1
			if b[i] == k:
				d = 0
	ans = 0
	d = 0
	for i in range(n - 1, -1, -1):
		if a[i] == '1':
			d = 0
		else:
			c[i] = d
			d += 1
	for i in range(n):
		if b[i] == k and c[i] >= k:
			ans += 1
	print(ans)
for _ in range(I()):
	solve()


import math
t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	(n, k) = (l[0], l[1])
	a = '1' + k * '0' + str(input()) + k * '0' + '1'
	(count, se, arr) = (0, 0, [])
	for i in range(1, len(a)):
		if a[i] == '0':
			count += 1
		else:
			arr.append(count)
			count = 0
	for i in arr:
		if i - 2 * k > 0:
			se += math.ceil((i - 2 * k) / (k + 1))
	print(se)


from sys import stdin, stdout
import math, collections

def solve():
	cases = int(input())
	for case in range(1, cases + 1):
		(n, k) = [int(n) for n in input().split()]
		s = input()
		prev = -1
		curr = -1
		ans = 0
		for (i, e) in enumerate(s):
			if e == '1':
				if curr == -1:
					curr = i
					diff = curr - prev - 1
					if diff >= k + 1:
						ans += diff // (k + 1)
				else:
					prev = curr
					curr = i
					diff = curr - prev - 1 - k * 2
					ans += math.ceil(diff / (k + 1))
		if curr == -1 and prev == -1:
			print(math.ceil(len(s) / (k + 1)))
		else:
			diff = len(s) - curr - 1
			if diff >= k + 1:
				ans += diff // (k + 1)
			print(ans)
solve()


TC = int(input())
for t_itr in range(TC):
	(N, K) = map(int, input().split())
	S = list(input())
	before = K
	result = 0
	for (i, s) in enumerate(S):
		if s == '0':
			before += 1
		else:
			before = 0
		if before > K:
			S[i] = '2'
			before = 0
	before = K
	for s in reversed(S):
		if s == '2':
			if before >= K:
				result += 1
			before = 0
		elif s == '1':
			before = 0
		else:
			before += 1
	print(result)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	free = s.split('1')
	s = '1' + k * '0' + s + k * '0' + '1'
	free = s.split('1')
	count = 0
	for i in free[1:-1]:
		count += (len(i) - 2 * k + k) // (k + 1)
	print(count)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	print()
	cnt = 0
	lastOneIdx = -k - 1
	for i in range(len(s)):
		if s[i] == '1':
			lastOneIdx = i
			continue
		if i - lastOneIdx == k + 1:
			broken = False
			for j in range(i, len(s)):
				if j - i == k + 1:
					cnt += 1
					lastOneIdx = i
					broken = True
					break
				if s[j] == '1':
					lastOneIdx = j
					broken = True
					break
			if broken == False:
				cnt += 1
				lastOneIdx = i
	print(cnt)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = str(input())
	l = list(s)
	if l.count('1') == 0:
		print(n // (k + 1) + int(n % (k + 1) != 0))
	else:
		(c, ans) = (0, 0)
		(fst, lst) = (0, n)
		for i in range(n):
			if l[i] == '0':
				c += 1
			else:
				fst = i
				if c - k > 0:
					ans += (c - k) // (k + 1) + int((c - k) % (k + 1) != 0)
				break
		c = 0
		for i in range(n - 1, -1, -1):
			if l[i] == '0':
				c += 1
			else:
				lst = i
				if c - k > 0:
					ans += (c - k) // (k + 1) + int((c - k) % (k + 1) != 0)
				break
		c = 0
		for i in range(fst, lst + 1):
			if l[i] == '0':
				c += 1
			else:
				if c - 2 * k > 0:
					ans += (c - 2 * k) // (k + 1) + int((c - 2 * k) % (k + 1) != 0)
				c = 0
		print(ans)


t = int(input())
for j in range(t):
	a = []
	a = list(map(int, input().split()))
	n = a[0]
	k = a[1]
	ans = 0
	s = str(input())
	a = list(range(n))
	for i in range(n):
		a[i] = int(s[i])
	for i in range(n):
		if a[i] == 1:
			for b in range(1, k + 1):
				if i + b <= n - 1 and a[i + b] != 1:
					a[i + b] = 2
				if i - b >= 0 and a[i - b] != 1:
					a[i - b] = 2
	for i in range(n):
		if a[i] == 0:
			ans += 1
			a[i] = 1
			for b in range(1, k + 1):
				if i + b <= n - 1 and a[i + b] == 0:
					a[i + b] = 2
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(input())
	for i in range(n):
		arr[i] = int(arr[i])
	indexarr = []
	count = 0
	for i in range(n):
		if arr[i] == 1:
			indexarr += [i]
	if indexarr == []:
		print((n + k) // (k + 1))
	else:
		for i in range(len(indexarr)):
			if i == 0:
				count += indexarr[0] // (k + 1)
			if i != len(indexarr) - 1:
				dif = indexarr[i + 1] - indexarr[i] - 1
				count += max(0, (dif - k) // (k + 1))
			if i == len(indexarr) - 1:
				dif = n - indexarr[-1] - 1
				count += dif // (k + 1)
		print(count)


T = int(input())
for _ in range(T):
	(N, K) = [int(s) for s in input().split()]
	S = input()
	zero = N
	res = 0
	for c in S:
		if c == '1':
			if zero < K:
				res -= 1
			zero = 0
		elif zero >= K:
			res += 1
			zero = 0
		else:
			zero += 1
	print(res)


import sys
from heapq import heapify, heappop, heappush
from itertools import *
from collections import *
from math import *
sys.setrecursionlimit(10 ** 6)
input = lambda : sys.stdin.readline()
inp = lambda : int(input())
nm = lambda : map(int, input().split())
arr = lambda : list(nm())
INF = int(1e+18) + 1
mod = int(1000000000.0) + 7

def solve():
	(n, m) = nm()
	s = input()[:-1]
	s = '0' * m + s + '0' * m
	lst = list(s.split('1'))
	cnt = 0
	for i in lst:
		ln = len(i)
		ln -= m
		cnt += ln // (m + 1)
	print(cnt)
t = inp()
for i in range(t):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	data = input()
	all_list = []
	now = []
	for i in range(n):
		if data[i] == '0':
			now.append('0')
		else:
			all_list.append(now)
			now = []
	all_list.append(now)
	answer = 0
	one_count = data.count('1')
	length = len(all_list)
	for i in range(length):
		now = all_list[i]
		if i == 0:
			if one_count >= 1:
				answer += len(now[:-k:k + 1])
			else:
				answer += len(now[::k + 1])
		elif i == length - 1:
			answer += len(now[k::k + 1])
		else:
			answer += len(now[k:-k:k + 1])
	print(answer)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	s = input()
	ones = 0
	zeros = 0
	i = 0
	c = 0
	while i < n:
		if s[i] == '0' and c % (k + 1) == 0:
			zeros = zeros + 1
			c = 0
		if s[i] == '1' and c % (k + 1) != 0:
			zeros = zeros - 1
			ones = ones + 1
			c = 0
		if s[i] == '1' and c % (k + 1) == 0:
			ones = ones + 1
			c = 0
		c = c + 1
		i = i + 1
	print(zeros)
	t = t - 1


def main():
	testCases = int(input())
	for _ in range(testCases):
		(n, k) = tuple(map(int, input().rstrip().split()))
		arr = list(input().rstrip())
		count = 0
		i = 0
		while i < n:
			if arr[i] == '1':
				i = i + k + 1
			else:
				j = 1
				while j <= k:
					if i + j < n:
						if arr[i + j] == '0':
							j += 1
						elif arr[i + j] == '1':
							i = i + j
							break
					else:
						count += 1
						j = 1
						i = n
						break
				if j == k + 1:
					count += 1
					i = i + k + 1
		print(count)
main()


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	ans = 0
	if s[:k + 1].count('1') == 0:
		s[0] = '1'
		ans += 1
	if s[-(k + 1):].count('1') == 0:
		s[-1] = '1'
		ans += 1
	p = [i + 1 for i in range(n) if s[i] == '1']
	for i in range(len(p) - 1):
		ans += math.ceil((p[i + 1] - p[i] - 2 * k - 1) / (k + 1))
	print(ans)


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque
from collections import defaultdict

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(n):
	tc = []
	ans = {}
	d = 2
	while d * d <= n:
		if n % d == 0:
			tc.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		tc.append(n)
	for i in tc:
		ans[i] = ans.get(i, 0) + 1
	return ans

def to_zero(n, s):
	lst = s[0]
	ans = []
	for i in range(n):
		if lst == s[i]:
			continue
		elif lst == '0':
			lst = '1'
			ans.append(i)
		else:
			lst = '0'
			ans.append(i)
	if lst == '1':
		ans.append(n)
	return ans
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	if s.count('1') == 0:
		if n > k:
			dop = 0
			if n % (k + 1) != 0:
				dop += 1
			print(n // (k + 1) + dop)
			continue
		else:
			print(1)
			continue
	a = []
	b = []
	lst = -1
	for i in range(n):
		if s[i] == '1':
			a.append(0)
			lst = i
		elif lst == -1:
			a.append(99999999999999999)
		else:
			a.append(i - lst)
	lst = -1
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			b.append(0)
			lst = i
		elif lst == -1:
			b.append(999999999999999999999999999)
		else:
			b.append(lst - i)
	c = []
	b = b[::-1]
	for i in range(n):
		c.append(min(a[i], b[i]))
	i = 0
	ans = 0
	while i < n:
		if c[i] == 0:
			i += k + 1
		elif c[i] > k:
			ans += 1
			i += k + 1
		else:
			i += 1
	print(ans)


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)


from sys import stdout, stdin
input = stdin.readline
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input().strip())
	j = -1
	m = -1
	count = 0
	b = []
	one = -1
	for i in range(n):
		if a[i] == '1':
			one = i
		b.append(one)
	for i in range(n):
		if a[i] == '1' and j == -1:
			j = i
		if a[i] == '1':
			j = i
		else:
			m = i
		if abs(j - m) - 1 == k and m != -1 and (j != -1) or (m % k == 0 and j == -1 and (m != -1)):
			if m + k < n:
				if b[m + k] < m:
					count += 1
					a[m] = '1'
					j = m
			elif b[n - 1] < m:
				count += 1
				a[m] = '1'
				j = m
	print(count)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, k) = list(map(int, stdin.readline().split()))
	s = list(stdin.readline().strip('\n'))
	ix = []
	ans = 0
	for i in range(n):
		if s[i] == '1':
			ix.append(i)
	if len(ix) == 0:
		print(1 + (n - 1) // (k + 1))
		continue
	for i in range(len(ix) - 1):
		l = ix[i]
		r = ix[i + 1] - k - 1
		ans += (r - l) // (k + 1)
	ans += ix[0] // (k + 1)
	ans += (n - 1 - ix[-1]) // (k + 1)
	print(ans)


t = int(input())
for i in range(t):
	[n, k] = list(map(int, input().split()))
	s = input()
	s = '1' + '0' * k + s + '0' * k + '1'
	count = 0
	ptr1 = ptr2 = 0
	for (j, c) in enumerate(s):
		if ptr1 - ptr2 > 2 * k:
			count += 1
			ptr2 = ptr1 - k
		if c == '1':
			if ptr1 - ptr2 > 2 * k:
				count += 1
			ptr1 += 1
			ptr2 = ptr1
		else:
			ptr1 += 1
	print(count)


for x in range(int(input())):
	(l, m) = map(int, input().split())
	s = input()
	if l == 1:
		if s[0] == '0':
			print(1)
		else:
			print(0)
	else:
		bb = []
		for y in s:
			bb.append(int(y))
		n = 0
		j = 0
		while j < l:
			if bb[j] == 0:
				d = j - m
				e = 0
				if d < 0:
					d = 0
				dd = j + m + 1
				if dd > l:
					dd = l
				a = sum(bb[d:dd])
				a1 = sum(bb[j + 1:dd])
				if a == 0:
					e = 0
				else:
					e = 1
				if e == 0:
					bb[j] = 1
					n += 1
					j = dd - 1
				elif a1 != 0:
					j = dd - 1
				else:
					j = j + 1
			else:
				j = j + m
		print(n)


T = int(input())
while T > 0:
	(n, k) = map(int, input().split())
	arr = input()
	index = -(k + 1)
	res = 0
	for i in range(n):
		if arr[i] == '0':
			if i - index - 1 >= k:
				res += 1
				index = i
		else:
			if i - index - 1 < k:
				res -= 1
			index = i
	print(res)
	T -= 1


import math
for _ in range(int(input())):
	(n, k) = list(map(int, input().rstrip().split()))
	table = input()
	i = 0
	z = 0
	one = 0
	while i < n and table[i] == '0':
		z += 1
		i += 1
	if z == n:
		z = int(math.ceil(z / (k + 1)))
		print(z)
		continue
	one = one + int(math.floor(z / (k + 1)))
	z = 0
	i += 1
	while i < n:
		if table[i] == '1':
			add = int(math.ceil((z - 2 * k) / (k + 1)))
			if add >= 0:
				one += add
			z = 0
		else:
			z += 1
		i += 1
	one = one + int(math.floor(z / (k + 1)))
	print(one)


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = int(input())
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	(n, k) = invr()
	s = insr()
	indexes = list()
	for i in range(n):
		if s[i] == '1':
			indexes.append(i + 1)
	last = 0
	count = 0
	if len(indexes) == 0:
		count = 1 + (n - 1) // (k + 1)
	for i in range(len(indexes)):
		x = indexes[i]
		if i == 0:
			if x > k:
				count += (x - 1) // (k + 1)
		else:
			dist = x - last - 1
			if dist > k:
				count += (dist + 1) // (k + 1) - 1
		if i == len(indexes) - 1:
			dist = n - x
			if dist > k:
				count += dist // (k + 1)
		last = x
	print(count)


t = int(input())
for p in range(0, t):
	(n, k) = map(int, input().split())
	st = input()
	p = [-1] * (n + 2)
	s = [-1] * (n + 2)
	if st[0] == '1':
		p[0] = 0
	if st[n - 1] == '1':
		s[n - 1] = n - 1
	for i in range(0, n):
		if st[i] == '1':
			p[i] = i
		else:
			p[i] = p[i - 1]
	for i in range(n - 2, -1, -1):
		if st[i] == '1':
			s[i] = i
		else:
			s[i] = s[i + 1]
	ans = 0
	(v1, v1) = (0, 0)
	for i in range(0, n):
		v1 = v2 = 10000000
		if p[i] != -1:
			v1 = i - p[i]
		if s[i] != -1:
			v2 = s[i] - i
		if min(v1, v2) > k:
			ans += 1
			p[i] = i
		if p[i + 1] < p[i]:
			p[i + 1] = p[i]
	print(ans)


t = int(input())
for l in range(t):
	ans = 0
	(n, k) = map(int, input().split())
	s = list(input())
	i = 0
	while i < n:
		if s[i] == '1':
			for j in range(i - 1, max(i - k - 1, -1), -1):
				s[j] = '1'
			for j in range(i + 1, min(i + k + 1, n)):
				s[j] = '1'
			i += k
		i += 1
	i = 0
	while i < n:
		if s[i] == '0':
			ans += 1
			i += k
		i += 1
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	li = input()
	l = []
	for i in range(n):
		l.append(int(li[i]))
	zero = l.count(0)
	one = l.count(1)
	if one == n:
		print(0)
	elif zero == n:
		x = n // (k + 1)
		if n % (k + 1) > 0:
			x += 1
		if x == 0:
			print(1)
		else:
			print(x)
	else:
		ini = -1
		count = 0
		for i in range(n):
			if l[i] == 1:
				fini = i
				if ini == -1:
					diff = fini
					count += diff // (k + 1)
					ini = i
				else:
					diff = abs(fini - ini)
					count += diff // (k + 1) - 1
					ini = i
		x = n - 1 - ini
		count += x // (k + 1)
		if count <= 0:
			print(0)
		else:
			print(count)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k += 1
	s = input()
	res = 0
	indo = set()
	for i in range(n):
		if s[i] == '1':
			for __ in range(i, i + k):
				if __ <= n - 1:
					indo.add(__)
			for __ in range(i, i - k, -1):
				if __ >= 0:
					indo.add(__)
	if len(indo) == 0:
		for i in range(0, n, k):
			res += 1
		print(res)
	else:
		for i in range(n):
			if i not in indo:
				res += 1
				for __ in range(i, i + k):
					if __ <= n - 1:
						indo.add(__)
				for __ in range(i, i - k, -1):
					if __ >= 0:
						indo.add(__)
		print(res)


import sys
read = lambda : sys.stdin.readline()
T = int(read())
for t in range(T):
	(n, k) = map(int, read().split())
	arr = read()
	num0 = [0]
	for i in range(n):
		if arr[i] == '0':
			num0[-1] += 1
		elif i > 0 and i < n - 1:
			num0.append(0)
	result = 0
	for i in range(len(num0)):
		if (i > 0 or arr[0] == '1') and (i < len(num0) - 1 or arr[n - 1] == '1'):
			result += max(0, (num0[i] - k) // (k + 1))
		elif len(num0) != 1 or arr[0] == '1' or arr[n - 1] == '1':
			result += max(0, num0[i] // (k + 1))
		else:
			result += max(0, (num0[i] + k) // (k + 1))
	print(result)


import sys, math
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, input().rstrip()))
	if 1 not in s:
		print(math.ceil(n / (k + 1)))
		continue
	for i in range(n):
		if s[i] == 1:
			left = max(0, i - k)
			right = min(i + k, n - 1)
			for j in range(left, right + 1):
				s[j] = -1
	result = 0
	for i in range(n):
		if s[i] == 0:
			result += 1
			left = max(0, i - k)
			right = min(i + k, n - 1)
			for j in range(left, right + 1):
				s[j] = -1
	print(result)


t = int(input())
for i in range(t):
	a = b = c = d = g = 0
	e = '1'
	f = str()
	(n, k) = map(int, input().split())
	s = str(input())
	if n <= k:
		for i in s:
			if i == '1':
				a = 1
				break
		if a == 1:
			print(0)
		else:
			print(1)
	else:
		for i in s[:k + 1]:
			if i == '1':
				b = 1
				e = s
				break
		if b == 0:
			d = d + 1
			for i in s[1:]:
				e = e + i
		for i in e[n - k - 1:]:
			if i == '1':
				g = 1
				f = e
				break
		if g == 0:
			d = d + 1
			for i in e[:n - 1]:
				f = f + i
			f = f + '1'
		for i in f:
			if i == '0':
				c = c + 1
			else:
				c = 0
			if c == 2 * k + 1:
				d = d + 1
				c = k
		print(d)


t = int(input())
cnt = 0
while cnt < t:
	cnt += 1
	(n, k) = map(int, input().split())
	a = [-k - 1]
	for (i, elem) in enumerate(input(), 0):
		if elem == '1':
			a.append(i)
	a.append(n + k)
	sz = len(a)
	res = 0
	for i in range(1, sz):
		res += (a[i] - a[i - 1]) // (k + 1) - 1
	print(res)


from itertools import groupby
from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	sl = []
	for (i, j) in groupby(s):
		w = len(list(j))
		sl.append([int(i), w])
	if sl[0][0] == 0 and sl[0][1] == n:
		v = n / (k + 1)
		if v == 0:
			print(1)
		else:
			print(ceil(v))
	else:
		total = 0
		if sl[0][0] == 0:
			total += sl[0][1] // (k + 1)
			del sl[0]
		if sl[len(sl) - 1][0] == 0:
			total += sl[len(sl) - 1][1] // (k + 1)
			del sl[len(sl) - 1]
		for i in sl:
			if i[0] == 0:
				g = i[1] - (2 * k + 1)
				if g >= 0:
					total += 1
					total += g // (k + 1)
		print(total)


for t in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	s = '0' * n + input() + '0' * n
	data = [0] * (3 * n)
	count = 0
	for i in range(2 * n):
		count += 1 if s[i + k] == '1' else 0
		count -= 1 if i >= k and s[i - k - 1] == '1' else 0
		data[i] = 1 if count else 0
	data = data[n:2 * n]
	count = 0
	flag = 0
	for i in range(n):
		if flag == 0 and data[i] == 0:
			flag = k
			count += 1
		else:
			flag = max(0, flag - 1)
	print(count)


for _ in range(int(input())):
	(n, k) = [int(s) for s in input().split()]
	s = input()
	arr = [-k - 1]
	found = False
	ind = -1
	for i in range(len(s)):
		if s[i] == '1':
			arr.append(i)
	arr.append(n + k)
	ans = 0
	if len(arr) == 2:
		print((n - 1) // (k + 1) + 1)
		continue
	for i in range(1, len(arr)):
		x = arr[i] - arr[i - 1]
		temp = x // (k + 1) - 1
		if temp >= 0:
			ans += temp
	print(ans)


import math as mt
import sys, string
input = sys.stdin.readline
from collections import defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for _ in range(t):
	(n, k) = M()
	s = input().strip()
	l = [0] * n
	last = -1
	c = 0
	for i in range(n - 1, -1, -1):
		if i != n - 1:
			l[i] = l[i + 1]
		else:
			l[i] -= 1
		if s[i] == '1':
			l[i] = i
	for i in range(n):
		if s[i] == '1':
			last = i
		if (l[i] - i > k or l[i] == -1) and (i - last > k or last == -1):
			c += 1
			last = i
	print(c)


from math import ceil
t = int(input())
while t:
	(n, k) = map(int, input().split())
	s = input()
	a = []
	a.append(-1)
	for i in range(n):
		if s[i] == '1':
			a.append(i)
	ans = 0
	a.append(n)
	for i in range(len(a) - 1):
		if a[i] == -1 and a[i + 1] == n:
			ans = ans + ceil(n / (k + 1))
		elif a[i] == -1:
			ans = ans + max(0, ceil((a[i + 1] - k) / (k + 1)))
		elif a[i + 1] == n:
			ans = ans + max(0, ceil((n - a[i] - 1 - k) / (k + 1)))
		else:
			ans = ans + max(0, ceil((a[i + 1] - a[i] - 1 - 2 * k) / (k + 1)))
	print(ans)
	t = t - 1


import math
import io
import os

def solve():
	(n, k) = map(int, input().split())
	total = 0
	s = input()
	sp = s.split('1')
	if len(sp) == 1:
		print(math.ceil(n / (k + 1)))
		return
	for (i, g) in enumerate(sp):
		l = len(g) - k
		if 0 < i < len(sp) - 1:
			l -= k
		total += max(0, math.ceil(l / (k + 1)))
	print(total)
t = int(input())
for _ in range(t):
	solve()


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, K) = MAP()
	A = input()
	cur = INF
	nxt = [0] * N
	for i in range(N - 1, -1, -1):
		if A[i] == '1':
			cur = i
		nxt[i] = cur
	ans = 0
	i = 0
	while i < N:
		if A[i] == '0':
			if nxt[i] - i > K:
				ans += 1
				i += K + 1
			else:
				i += 1
		else:
			i += K + 1
	print(ans)


t = int(input())
import math
delay = []
for _ in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	s = input()
	firstOne = -1
	for i in range(n):
		if s[i] == '1':
			firstOne = i
			break
	if firstOne == -1:
		print(max(1, math.ceil(n / (k + 1))))
		continue
	trail = []
	cnt = 0
	for i in range(firstOne + 1, n):
		if s[i] == '0':
			cnt += 1
		if i < n - 1 and s[i + 1] == '1' and (s[i] == '0'):
			trail.append(cnt)
			cnt = 0
	ans = 0
	ans += max(0, math.ceil((firstOne - k) / (k + 1)))
	ans += max(0, math.ceil((cnt - k) / (k + 1)))
	for t in trail:
		ans += max(0, math.ceil((t - 2 * k) / (k + 1)))
	print(ans)


import math
t = int(input())
for w in range(t):
	(n, k) = (int(i) for i in input().split())
	s = list(input())
	d = {1: []}
	for i in range(n):
		if s[i] == '1':
			d[1] += [i]
	k1 = len(d[1])
	if k1 == 0:
		print(math.ceil(n / (k + 1)))
	else:
		c1 = 0
		if d[1][0] > k:
			c1 += math.ceil((d[1][0] - k) / (k + 1))
		for i in range(k1 - 1):
			if d[1][i + 1] - d[1][i] - 1 > 2 * k:
				c1 += math.ceil((d[1][i + 1] - d[1][i] - 1 - 2 * k) / (k + 1))
		if n - (d[1][k1 - 1] + 1) > k:
			c1 += math.ceil((n - (d[1][k1 - 1] + 1) - k) / (k + 1))
		print(c1)


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


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	wow = set()
	output = 0
	for (i, x) in enumerate(s):
		if x == '1':
			wow.update([x for x in range(i - k, i + k + 1)])
	for i in range(n):
		if i not in wow:
			output += 1
			wow.update([x for x in range(i - k, i + k + 1)])
	print(output)


import sys

def input():
	return sys.stdin.readline().rstrip()

def input_split():
	return [int(i) for i in input().split()]
t = int(input())
for tests in range(t):
	(n, k) = input_split()
	s = input()
	safe = [True for i in range(n)]
	ind = 0
	while ind < n:
		if s[ind] == '1':
			j = 0
			while ind < n and j <= k:
				safe[ind] = False
				j += 1
				ind += 1
		else:
			ind += 1
	ind = n - 1
	while ind >= 0:
		if s[ind] == '1':
			j = 0
			while ind >= 0 and j <= k:
				safe[ind] = False
				j += 1
				ind -= 1
		else:
			ind -= 1
	cnt = 0
	ind = 0
	while ind < n:
		if safe[ind] == True:
			cnt += 1
			ind += k + 1
		else:
			ind += 1
	print(cnt)


from math import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = str(input())
	value = 0
	lis = []
	for i in range(0, n):
		if s[i] == '1':
			lis.append(i)
	if len(lis) == 0:
		noz = n
		value = ceil(n / (k + 1))
	elif len(lis) == 1:
		value += ceil(max(0, lis[0] - k) / (k + 1))
		value += ceil((n - 1 - min(lis[-1] + k, n - 1)) / (k + 1))
	else:
		value += ceil(max(0, lis[0] - k) / (k + 1))
		value += ceil((n - 1 - min(lis[-1] + k, n - 1)) / (k + 1))
		for i in range(1, len(lis)):
			noz = max(0, lis[i] - k - (lis[i - 1] + k)) - 1
			value += ceil(noz / (k + 1))
	print(value)


import os
import sys
from io import BytesIO, IOBase
from itertools import groupby
import math

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split(' '))
		s = '0' * k + input() + '0' * k
		a = [[x, len(list(y))] for (x, y) in groupby(s)]
		n = len(a)
		cnt = 0
		for x in range(n):
			if x == 0 or x == n - 1:
				if a[x][0] == '0':
					temp = math.floor((a[x][1] - k) / (k + 1))
					cnt += temp if temp >= 0 else 0
			elif a[x][0] == '0':
				temp = math.floor((a[x][1] - k) / (k + 1))
				cnt += temp if temp >= 0 else 0
		print(cnt)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for tc in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(input())
	ar = [int(i) for i in ar]
	left = [-1 for i in range(n)]
	right = [-1 for i in range(n)]
	ans = 0
	ones = -1
	for i in range(n - 1, -1, -1):
		if ar[i] == 1:
			ones = i
		right[i] = ones
	left = -1
	for i in range(n):
		if ar[i] == 1:
			left = i
		if (abs(i - left) > k or left == -1) and (abs(i - right[i]) > k or right[i] == -1):
			ans += 1
			left = i
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = input()
	count = 0
	j = 0
	while j < n:
		if l[j] == '0':
			m = j
			flag = 0
			while m <= j + k and m < n:
				if l[m] == '1':
					flag = 1
					break
				else:
					flag = 0
				m += 1
			if flag == 0:
				count += 1
				j += k + 1
			else:
				j = m + k + 1
		else:
			j += k + 1
	print(count)


from math import ceil
from collections import deque
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	s = input()
	j = 0
	d = 0
	ans = 0
	while j < n:
		if s[j] == '1':
			d = k
		elif d > 0:
			d = max(0, d - 1)
		else:
			for i in range(k):
				j += 1
				if j >= n:
					break
				if s[j] == '1':
					d = k
				else:
					d = max(0, d - 1)
			if d == 0:
				ans += 1
		j += 1
	print(ans)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	c = 0
	if s[0] == '0':
		c += 1
	p1 = 0
	for i in range(1, len(s), 1):
		if '1' in s[i]:
			if i - p1 - k <= 0:
				c -= 1
			p1 = i
		elif i - p1 - k > 0:
			c += 1
			p1 = i
	print(c)


t = int(input())
for gsdagsa in range(t):
	(n, k) = list(map(int, input().split()))
	u = [0] * n
	r = []
	j = 0
	res = 0
	a = list(map(int, list(input())))
	e1 = 0
	e2 = 0
	if a[0] == 1:
		e1 = 1
	if a[-1] == 1:
		e2 = 1
	for i in range(n):
		if a[i] == 0:
			u[j] += 1
		else:
			j += 1
	for i in range(n):
		if u[i] != 0:
			r.append([i, (u[i] - k) // (k + 1)])
	if e1 == 0:
		r[0][1] = u[r[0][0]] // (k + 1)
	if e2 == 0:
		r[-1][1] = u[r[-1][0]] // (k + 1)
	for i in range(len(r)):
		if r[i][1] > 0:
			res += r[i][1]
	if 1 not in a:
		print(max((n + k) // (k + 1), 1))
	else:
		print(res)


for _ in range(int(input())):
	t = [int(x) for x in input().split()]
	(n, k) = t
	s = input()
	o = 0
	ones = []
	for i in range(n):
		if s[i] == '1':
			ones.append(i)
	if len(ones) == 0:
		print(1 + (n - 1) // (k + 1))
	else:
		s = ones[0] // (k + 1) + (n - ones[-1] - 1) // (k + 1)
		for i in range(1, len(ones)):
			d = ones[i] - ones[i - 1] - 1
			s += (d - k) // (k + 1)
		print(s)


import sys
from math import ceil
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def list_input():
	return list(map(int, input().split()))

def sep_input():
	return map(int, input().split())
for _ in range(int(input())):
	(n, k) = sep_input()
	s = list(input())
	l = [int(i) for i in s]
	st = []
	for i in range(n):
		if l[i] == 1:
			st.append(i)
	if n <= k:
		if len(st) > 0:
			print(0)
		else:
			print(1)
	elif len(st) == 0:
		print(ceil(n / (k + 1)))
	else:
		c = 0
		for i in range(len(st) - 1):
			temp = st[i + 1] - st[i] - 1
			temp -= 2 * k
			if temp > 0:
				c += ceil(temp / (k + 1))
		c += max(0, ceil((st[0] - k) / (k + 1)))
		c += max(0, ceil((n - st[-1] - 1 - k) / (k + 1)))
		print(c)


n = int(input())
for i in range(n):
	(m, k) = [int(i) for i in input().split()]
	a = [int(i) for i in list(input())]
	if a == [0] * m:
		print((m + k) // (k + 1))
	else:
		first_appear = 0
		while a[first_appear] != 1:
			first_appear += 1
		last_appear = 0
		while a[len(a) - 1 - last_appear] != 1:
			last_appear += 1
		l = first_appear // (k + 1) + last_appear // (k + 1)
		counter = 0
		for j in range(first_appear, len(a) - last_appear):
			if a[j] == 0:
				counter += 1
			else:
				if counter // (k + 1) != 0:
					l += (counter + 1) // (k + 1) - 1
				counter = 0
		print(l)


import math as m
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ans = 0
	c = 0
	l = 0
	for i in range(n):
		if s[i] == '0':
			c += 1
		else:
			c = c - k
			if c > 0:
				ans += m.ceil(c / (k + 1))
			c = -1 * k
	if c > 0:
		ans = ans + m.ceil(c / (k + 1))
	print(ans)


def solution():
	(n, k) = list(map(int, input().split()))
	s = input()
	reqGap = 2 * k + 1
	prev = -k - 1
	count = 0
	for i in range(n):
		if i - prev > reqGap:
			count += 1
			prev = i - k - 1
		if s[i] == '1':
			prev = i
	if s[n - 1] != '1' and n - 1 - prev > k:
		count += 1
	print(count)
T = int(input())
while T:
	solution()
	T -= 1


t = int(input())
while t > 0:
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	s = input()
	(ans, i, z) = (0, 0, 0)
	while i < n and s[i] != '1':
		z += 1
		i += 1
	if i == n:
		if n % (k + 1) > 0:
			ans = 1
		ans = ans + n // (k + 1)
	else:
		ans = ans + z // (k + 1)
		(st, i, z) = (i, n - 1, 0)
		while i > st and s[i] != '1':
			z += 1
			i -= 1
		ans = ans + z // (k + 1)
		(ed, i) = (i, st)
		while i < ed:
			i += 1
			z = 0
			while i < ed and s[i] != '1':
				z += 1
				i += 1
			z = z - k
			ans = ans + z // (k + 1)
	print(ans)
	t -= 1


t = int(input())
for q in range(t):
	(n, k) = [int(i) for i in input().split(' ')]
	a = [1] + [0 for i in range(k)] + [int(i) for i in input()] + [0 for i in range(k)] + [1]
	o = []
	for i in range(len(a)):
		if a[i] == 1:
			o.append(i)
	answ = 0
	for i in range(len(o) - 1):
		if o[i] + k < o[i + 1] - k - 1:
			lul = o[i + 1] - k - 1 - o[i] - k
			if lul % (k + 1) != 0:
				answ += lul // (k + 1) + 1
			else:
				answ += lul // (k + 1)
	print(answ)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	occupied = [False] * n
	for i in range(n):
		if s[i] == '1':
			for j in range(i - k, i + k + 1):
				if j in range(n):
					occupied[j] = True
	count = [0] * n
	if occupied[0]:
		count[0] = 0
	else:
		count[0] = 1
	for i in range(n):
		if not occupied[i]:
			count[i] = count[i - 1] + 1
	ans = 0
	for i in range(n - 1):
		if count[i] > count[i + 1]:
			ans += math.ceil(count[i] / (k + 1))
	ans += math.ceil(count[n - 1] / (k + 1))
	print(ans)


def solution(A, k):
	remaining = 0
	for (i, value) in enumerate(A):
		if value == 1:
			remaining = k
			continue
		if remaining != 0:
			A[i] = 2
			remaining -= 1
	for (i, value) in list(enumerate(A))[::-1]:
		if value == 1:
			A[i] = 2
			remaining = k
			continue
		if remaining != 0:
			A[i] = 2
			remaining -= 1
	num = 0
	prev = float('-inf')
	for i in range(len(A)):
		if A[i] == 0 and i - prev > k:
			num += 1
			prev = i
	return num

def parse():
	num = int(input().rstrip())
	for _ in range(num):
		k = int(input().rstrip().split(' ')[1])
		A = list(map(int, list(input().rstrip())))
		print(solution(A, k))
parse()


from math import ceil, log, floor, sqrt
import math

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def find_k(x, y, n):
	return (n - y) // x * x + y

def count_sticks(n):
	if n % 2 == 0:
		return n // 2
	return n // 2 + 1

def get_types(n, r):
	if r < n:
		return r * (r + 1) // 2
	r = n - 1
	return r * (r + 1) // 2 + 1

def happy_guests(a, b, n, m):
	mn = min(n, m)
	a -= mn
	b -= mn
	n -= mn
	m -= mn
	if a < 0 or b < 0:
		return False
	if n > 0:
		return a + b >= n
	return min(a, b) >= m

def count_vacancies(n, k, s):
	indices = []
	cnt = 0
	for i in range(n):
		if s[i] == '1':
			indices.append(i)
	if len(indices) == 0:
		return (n + k) // (1 + k)
	cnt = indices[0] // (1 + k)
	for i in range(len(indices) - 1):
		delta = indices[i + 1] - indices[i] - 1
		cnt += (delta - k) // (1 + k)
	delta = n - (indices[len(indices) - 1] + 1)
	cnt += delta // (1 + k)
	return cnt
t = 1
t = int(input())
while t:
	t = t - 1
	(n, k) = map(int, input().split())
	s = input()
	print(count_vacancies(n, k, s))


def fill(a, b, k):
	if a > b:
		return 0
	return (b - a) // (k + 1)

def fillLast(a, b, k):
	if a > b:
		return 0
	if (b - a) % (k + 1) == 0:
		return (b - a) // (k + 1)
	return (b - a) // (k + 1) + 1
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	table = input()
	next = 0
	ans = 0
	for i in range(n):
		if table[i] == '1':
			ans += fill(next, i, k)
			next = i + k + 1
	ans += fillLast(next, n, k)
	print(ans)


import sys
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
from collections import defaultdict as df
t = int(input().strip())
for _ in range(t):
	(n, k) = RI()
	s = input().strip()
	f = 0
	k = k + 1
	for i in s:
		if i == '1':
			f = 1
	if f == 0:
		print((n + k - 1) // k)
		continue
	cur = 0
	last = -1
	ans = 0
	kr = k - 1
	while cur < n:
		if s[cur] == '1':
			if last == -1:
				x = cur - last - 1 - kr
				if x > 0:
					ans += (x + k - 1) // k
				last = cur
				cur += 1
			else:
				x = cur - last - 1 - 2 * kr
				if x > 0:
					ans += (x + k - 1) // k
				last = cur
				cur += 1
		else:
			cur += 1
	x = cur - last - 1 - kr
	if x > 0:
		ans += (x + k - 1) // k
	print(ans)


testcases = int(input())
for x in range(testcases):
	(n, k) = [int(i) for i in input().split()]
	s = '0' * k + input() + '0' * k
	l = s.split('1')
	d = k + 1
	c = 0
	for x in l:
		c += max(0, (len(x) - k) // d)
	print(c)


import io
import os
from collections import Counter, defaultdict, deque

def makeRepeat(arr):
	repeat = [[arr[0], 0]]
	for x in arr:
		if x == repeat[-1][0]:
			repeat[-1][1] += 1
		else:
			repeat.append([x, 1])
	return repeat

def solve(N, K, S):
	if '1' not in S:
		return 1 + (N - 1) // (K + 1)
	repeats = makeRepeat(S)
	ans = 0
	for (i, (ch, count)) in enumerate(repeats):
		if ch == '0':
			if i == 0 or i == len(repeats) - 1:
				ans += count // (K + 1)
			else:
				assert count >= K
				ans += (count - K) // (K + 1)
	return ans
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N, K) = [int(x) for x in input().split()]
	S = input().decode().rstrip()
	ans = solve(N, K, S)
	print(ans)


t = int(input())
while t:
	(n, k) = [int(i) for i in input().split()]
	s = input()
	ans = 0
	left = [n + k + i for i in range(n)]
	right = [n + k + i for i in range(n)]
	if s[0] == '1':
		left[0] = 0
	if s[n - 1] == '1':
		right[n - 1] = 0
	for i in range(1, n):
		if s[i] == '1':
			left[i] = 0
		else:
			left[i] = left[i - 1] + 1
	for i in range(n - 2, -1, -1):
		if s[i] == '1':
			right[i] = 0
		else:
			right[i] = right[i + 1] + 1
	prev = 0
	ans = 0
	for i in range(n):
		if s[i] == '1':
			prev = 0
		if s[i] == '0':
			if left[i] - prev > k and right[i] > k:
				ans += 1
				prev = left[i]
	print(ans)
	t -= 1


from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
from collections import Counter
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	prefones = [0] * n
	for (ind, i) in enumerate(s):
		if i == '1':
			prefones[ind] = 1
	for i in range(1, n):
		prefones[i] += prefones[i - 1]
	i = 0
	ans = 0
	while i < n:
		if s[i] == '0':
			if prefones[min(n - 1, i + k)] - prefones[i] == 0:
				ans += 1
				i += k + 1
			else:
				i += 1
		else:
			i += k + 1
	print(ans)


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 = list(input())
	t = 0
	ans = 0
	if s[0] == '0':
		ans += 1
		t = 0
	i = 1
	while i < n:
		if s[i] == '1':
			if i - t - k <= 0:
				ans -= 1
			t = i
		elif i - t - k > 0:
			ans += 1
			t = i
		i += 1
	print(ans)


from math import ceil
for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	string = input()
	cnt = 0
	temp = []
	ans = 0
	temp = list(string.split('1'))
	for i in range(len(temp)):
		if temp[i] == '':
			temp[i] = '0'
	if len(temp) == 1:
		print(ceil(len(temp[0]) / (k + 1)))
		continue
	first = max(0, len(temp[0]) - k)
	ans += ceil(first / (k + 1))
	if len(temp) > 1:
		last = max(0, len(temp[-1]) - k)
		ans += ceil(last / (k + 1))
	for i in range(1, len(temp) - 1):
		ans += ceil(max(0, len(temp[i]) - 2 * k) / (k + 1))
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	count = 0
	if '1' not in s:
		print(1 + (len(s) - 1) // (k + 1))
		continue
	res = s.split('1')
	for i in range(1, len(res) - 1):
		tmp = len(res[i]) - 2 * k
		count += 1 + (tmp - 1) // (k + 1)
	if len(res) >= 2:
		tmp = len(res[0]) - k
		count += 1 + (tmp - 1) // (k + 1)
		tmp = len(res[-1]) - k
		count += 1 + (tmp - 1) // (k + 1)
		print(count)
	else:
		tmp = len(res[0]) - k
		count += 1 + (tmp - 1) // (k + 1)
		print(count)


for i in range(int(input())):
	(n, k) = map(int, input().split(' '))
	a = list(input())
	ans = 0
	zer = 0
	for b in range(n):
		if a[b] == '0':
			zer += 1
			if zer == k + 1:
				ans += 1
				zer = 0
			elif zer > 0 and b == n - 1:
				ans += 1
		else:
			zer = -k
	print(ans)


t = int(input())
import math
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = input()
	a = []
	summer = 0
	for i in range(len(s)):
		if s[i] == '1':
			a.append(i)
	i = 0
	while i < len(a) - 1:
		dist = a[i + 1] - k - 1 - (a[i] + k + 1) + 1
		if dist > 0:
			summer += math.ceil(dist / (k + 1))
		i += 1
	if len(a) > 0:
		dist = a[0] - k
		if dist > 0:
			summer += math.ceil(dist / (k + 1))
		dist = n - 1 - a[-1] - k
		if dist > 0:
			summer += math.ceil(dist / (k + 1))
	else:
		summer += math.ceil(n / (k + 1))
	print(summer)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = [int(i) for i in input()]
	ind = 0
	counter = 0
	while ind < n:
		if s[ind] == 1:
			ind += k + 1
		else:
			(ind1, ind2) = (ind - 1, ind + 1)
			(k1, k2) = (k, k)
			(flag1, flag2) = (0, 0)
			while ind1 >= 0 and k1 != 0:
				if s[ind1] == 0:
					ind1 -= 1
					k1 -= 1
				else:
					flag1 = 1
					break
			while ind2 < n and k2 != 0:
				if s[ind2] == 0:
					ind2 += 1
					k2 -= 1
				else:
					flag2 = 1
					break
			if flag1 == 0 and flag2 == 0:
				counter += 1
				s[ind] = 1
				ind = ind2
			elif flag1 == 1 and flag2 == 0:
				ind += 1
			else:
				ind = ind2
	print(counter)


def inpi():
	return int(input())

def inps():
	return str(input())

def inparr():
	return list(map(int, input().split()))

def inptup():
	return map(int, input().split())
for _ in range(inpi()):
	(n, k) = inptup()
	s = inps()
	flag = True
	c = 0
	ans = 0
	for i in range(n):
		if flag:
			if s[i] == '0':
				c += 1
			else:
				if i != 0:
					ans += c // (k + 1)
					c = 0
				flag = False
		elif s[i] == '0':
			c += 1
		else:
			c -= k
			if c > 0:
				ans += c // (k + 1)
			c = 0
	if flag:
		c -= 1
		ans += 1
		if c > 0:
			ans += c // (k + 1)
		c = 0
	elif c > 0:
		ans += c // (k + 1)
	print(ans)


ncases = int(input())
a = []
for i in range(ncases):
	take = input().split(' ')
	n = int(take[0])
	k = int(take[1])
	state = list(input())
	if '1' not in state:
		for j in range(0, len(state), k + 1):
			state[j] = '1'
		a.append(state.count('1'))
	else:
		first = state.index('1')
		ini = state.count('1')
		while first - (k + 1) >= 0:
			state[first - (k + 1)] = '1'
			first = first - (k + 1)
		temp = 99999999999
		for l in range(first, len(state)):
			if k != 0:
				if state[l] == '0':
					k -= 1
				elif state[l] == '1':
					k = int(take[1])
					if temp < len(state):
						state[temp] = '0'
			elif k == 0:
				if state[l] == '0':
					state[l] = '1'
					temp = l
					k = int(take[1])
				elif state[l] == '1':
					k = int(take[1])
		fin = state.count('1')
		a.append(fin - ini)
for ele in a:
	print(ele)


def fun(arr, n, k):
	ans = 0
	pre = [0] * (n + 1)
	for i in range(n):
		pre[i + 1] = pre[i] + int(arr[i])
	i = 0
	while i < n:
		if arr[i] == '1':
			i += k + 1
		else:
			val = min(n, i + k + 1)
			if pre[val] - pre[i + 1] == 0:
				ans += 1
				i += k + 1
			else:
				i += 1
	return ans
t = int(input())
while t:
	(n, k) = map(int, input().split())
	s = input()
	print(fun(s, n, k))
	t -= 1


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(map(int, list(s[:len(s) - 1])))

def invr():
	return map(int, input().split())
from collections import Counter

def main():
	t = inp()
	for _ in range(t):
		(n, k) = inlt()
		nums = insr()
		nums = [0] * k + nums + [0] * k
		res = 0
		zeros = 0
		for (i, num) in enumerate(nums):
			if num == 0:
				zeros += 1
				if zeros == 2 * k + 1:
					zeros = k
					res += 1
			else:
				zeros = 0
		print(res)
main()


import sys
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

def solve():
	(n, k) = I()
	s = input()
	ans = 0
	last = -INF
	for i in range(n):
		if s[i] == '1':
			if i - last <= k:
				ans -= 1
			last = i
			count = 0
			continue
		if i - last > k:
			ans += 1
			last = i
	print(ans)
(t,) = I()
while t:
	t -= 1
	solve()


from sys import stdin, stdout

def input():
	return stdin.readline()

def prin(x):
	return stdout.write(str(x) + '\n')
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	l = []
	c = 0
	for i in range(n):
		if s[i] == '1':
			l.append(i + 1)
	N = len(l)
	c = 0
	if N == 0:
		l.append(1)
		c += 1
	if l[0] > 1:
		x = l[0] - 1
		x = x // (k + 1)
		c += x
	if l[N - 1] < n:
		x = n - l[N - 1]
		x = x // (k + 1)
		c += x
	for i in range(N - 1):
		x = l[i]
		y = l[i + 1]
		z = y - x - 1
		z = (z - k) // (k + 1)
		c += z
	print(c)


test = eval(input())
for i in range(test):
	numbers = input().split()
	n = int(numbers[0])
	k = int(numbers[1])
	s = input()
	cnt = 0
	j = 0
	while j < n:
		if s[j] == '0':
			flag = 0
			for step in range(j, min(j + k + 1, n)):
				if s[step] == '1':
					flag = step
					break
			if flag == 0:
				cnt += 1
				j += k + 1
			else:
				j = flag + k + 1
		else:
			j += k + 1
	print(cnt)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	l = list(input())
	f = 0
	c = 0
	if a > b:
		x = b + 1
	else:
		x = b
	for i in range(x):
		if l[i] == '1':
			f = 1
			break
	if f == 0:
		l[0] = '1'
		c += 1
	s = 0
	for i in range(len(l)):
		if l[i] == '0':
			s = s + 1
			if s >= 2 * b + 1:
				s = b
				c += 1
		else:
			s = 0
	if s > b:
		c += 1
	print(c)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = input()
	count = 0
	ans = 0
	import math
	flag = 0
	for num in arr:
		if num == '1':
			if flag == 0:
				count -= k
			else:
				count -= 2 * k
			if count > 0:
				ans += math.ceil(count / (k + 1))
			count = 0
			flag = 1
		else:
			count += 1
	if flag == 1:
		count -= k
	if count > 0:
		ans += math.ceil(count / (k + 1))
	print(ans)