#include <bits/stdc++.h>
using namespace std;
long long int MX = 1e18;
long long int MN = -MX;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, l, a, b, c, d, q, s, n, m, o, p, tc = 1, jj, z, aa;
  cin >> tc;
  for (jj = 0; jj < tc; jj++) {
    vector<long long int> vv;
    map<long long int, long long int> uu;
    string str;
    cin >> n >> k >> str;
    for (i = 0; i < str.length();) {
      if (str[i] == '1') {
        uu[i] = 1;
        for (int j = 1; j <= k; j++) {
          uu[i + j] = 1;
        }
        i = i + k;
      }
      i++;
    }
    z = str.size() - 1;
    for (i = z; i >= 0;) {
      if (str[i] == '1') {
        uu[i] = 1;
        for (int j = 1; j <= k; j++) {
          uu[i - j] = 1;
        }
        i = i - k;
      }
      i--;
    }
    int cnt = 0, ans = 0;
    for (i = 0; i < str.length(); i++) {
      if (!uu[i]) {
        cnt++;
      } else {
        if (cnt % (k + 1) == 0)
          ans += (cnt / (k + 1));
        else
          ans += (cnt / (k + 1) + 1);
        cnt = 0;
      }
    }
    if (cnt % (k + 1) == 0)
      ans += (cnt / (k + 1));
    else
      ans += (cnt / (k + 1) + 1);
    cout << ans << endl;
  }
}
