#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int check[n];
    int dis1 = 0;
    int dis2 = 0;
    for (int i = 0; i < n; ++i) {
      check[i] = 0;
    }
    int d = k;
    int f = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        d++;
      } else {
        d -= k;
        f += d / (k + 1);
        d = 0;
      }
    }
    cout << f + d / (k + 1) << '\n';
  }
}
