#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int N = 1e5;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int n, k, ans = 0, a[200005] = {0}, b[200005] = {0};
    string str;
    cin >> n >> k >> str;
    b[str.size()] = INF;
    for (int i = str.size() - 1; i >= 0; i--) {
      if (str[i] == '1')
        b[i] = i;
      else
        b[i] = b[i + 1];
    }
    for (int i = 0; i < str.size(); i++) {
      if (str[i] == '1')
        a[i] = i;
      else {
        if (i > 0)
          a[i] = a[i - 1];
        else
          a[i] = -INF;
      }
      if (i - a[i] > k && b[i] - i > k) {
        ans++;
        a[i] = i;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
