#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1e5 + 50;
int a[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    string s;
    cin >> n >> k >> s;
    int ans = 0;
    int o = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') {
        o = k;
        a[i] = 1;
      } else if (o > 0) {
        a[i] = 1;
        o--;
      } else {
        a[i] = 0;
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (s[i] == '1') {
        o = k;
        a[i] = 1;
      } else if (o > 0) {
        a[i] = 1;
        o--;
      }
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == 0) {
        ans++;
        i += k;
      }
    }
    int anss = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] == 0) {
        anss++;
        i -= k;
      }
    }
    cout << max(ans, anss) << endl;
  }
}
