#include <bits/stdc++.h>
char a[200009];
int b[200009];
int main() {
  int t;
  scanf("%d", &t);
  int n, k;
  while (t--) {
    scanf("%d%d", &n, &k);
    getchar();
    scanf("%s", a);
    memset(b, 0, sizeof(b));
    int len = 0;
    int flag = 0;
    for (len; a[len] != '\0'; len++)
      ;
    for (int i = 0; a[i] != '\0'; i++) {
      int l = i - k > 0 ? i - k : 0;
      int r = i + k >= len ? len : i + k + 1;
      if (a[i] == '1') {
        for (l; l < r; l++) {
          if (a[l] == '1' && l != i) {
            flag = 1;
            break;
          }
        }
        if (flag == 0) {
          l = i - k > 0 ? i - k : 0;
          for (l; l < r; l++) {
            b[l] = -1;
          }
        }
      }
      if (flag == 1) break;
    }
    int sum = 0;
    if (flag != 1)
      for (int i = 0; i < len; i++) {
        if (b[i] == 0) {
          sum++;
          int l = i - k > 0 ? i - k : 0;
          int r = i + k >= len ? len : i + k + 1;
          for (l; l < r; l++) {
            b[l] = -1;
          }
        }
      }
    printf("%d\n", sum);
  }
  return 0;
}
