#include <bits/stdc++.h>
using namespace std;
int t, n, k, A[200002];
string s;
void ones(int &i) {
  int temp = k, y = i;
  while (temp-- and i++ < n) {
    s[i] = '1';
  }
  temp = k;
  while (temp-- and y--) {
    s[y] = '1';
  }
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> k >> s;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] - '0') {
        ones(i);
      }
    }
    for (int i = 0; i < n; i++)
      if (s[i] - '0' == 0) {
        cnt++;
        ones(i);
      }
    cout << cnt << "\n";
  }
}
