#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)(1e17 + 17);
const long long mod = (long long)(1e9 + 7);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T;
  cin >> T;
  while (T--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<long long> ones;
    for (long long i = 0; i < n; i++)
      if (s[i] == '1') ones.push_back(i);
    long long last = -inf;
    ones.push_back(inf);
    long long ct = 0;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '1')
        last = i;
      else {
        long long next = *upper_bound(ones.begin(), ones.end(), i);
        if (abs(i - last) > k and abs(next - i) > k) {
          ct++;
          last = i;
        }
      }
    }
    cout << ct << "\n";
  }
  return 0;
}
