import java.io.*;
import java.util.*;

public class revolutions_vd_slow {

	boolean fine(int[] a, int i, int j, int k) {
		int cnt = 0;
		for (int t = i; t <= j; t++) {
			if (cnt < k) {
				cnt += 1 - a[t];
			} else {
				cnt += a[t];
			}
		}
		return cnt >= 2 * k && a[i] == 0 && a[j] == 1;
	}

	public void solve() throws IOException {
		int n = nextInt();
		int k = nextInt();
		String s = next();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = s.charAt(i) - '0';
		}
		int res = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (fine(a, i, j, k) && !fine(a, i, j, k + 1)) {
					res++;
				}
			}
		}
		out.println(res);

	}

	final String fileName = "revolutions_vd_slow_".split("_")[0];

	public void run() throws IOException {
		br = new BufferedReader(new FileReader(fileName + ".in"));
		out = new PrintWriter(fileName + ".out");
		int t = nextInt();
		for (int i = 0; i < t; i++) {
			solve();
		}
		out.close();
		br.close();
	}

	public static void main(String[] args) throws IOException {
		new revolutions_vd_slow().run();
	}

	BufferedReader br;
	StringTokenizer str;
	PrintWriter out;

	String next() throws IOException {
		while (str == null || !str.hasMoreTokens()) {
			str = new StringTokenizer(br.readLine());
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

}
