#include <bits/stdc++.h>
using namespace std;
int main() {
  long long test, n, k;
  cin >> test;
  while (test--) {
    cin >> n >> k;
    string a;
    long long soln = 0;
    cin >> a;
    for (int i = 0; i < n;) {
      if (a[i] == '1') {
        int j = i + 1;
        for (; j <= i + k && j < n; j++) {
          if (a[j] == '1') {
            break;
          }
        }
        i = j;
      } else {
        int j = i + 1;
        bool found = false;
        for (; j <= i + k && j < n; j++) {
          if (a[j] == '1') {
            found = true;
            break;
          }
        }
        if (!found) {
          a[i] = '1';
          soln++;
        }
        i = j;
      }
    }
    cout << soln << "\n";
  }
  return 0;
}
