#include <bits/stdc++.h>
const double pi = acos(-1.0);
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    int n, k, ans = 0, count = 0;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> a;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') {
        count++;
        if (i - k < 0) {
          a.push_back(0);
        } else {
          a.push_back(i - k);
        }
        if (i + k > n - 1) {
          a.push_back(n - 1);
        } else
          a.push_back(i + k);
      }
    }
    if (count == 0) {
      cout << n / (k + 1) + (n % (k + 1) != 0) << "\n";
      continue;
    }
    for (int i = 1; i < a.size() - 2; i += 2) {
      if (a[i] >= a[i + 1]) continue;
      int f = a[i + 1] - a[i] - 1;
      if (f == 0) continue;
      ans = ans + f / (k + 1) + (f % (k + 1) != 0);
    }
    if (a[0] > 0) {
      ans = ans + a[0] / (k + 1) + (a[0] % (k + 1) != 0);
    }
    if (a[a.size() - 1] < n - 1) {
      int f = n - 1 - a[a.size() - 1];
      ans = ans + f / (k + 1) + (f % (k + 1) != 0);
    }
    if (ans < 0) {
      cout << 0 << "\n";
      continue;
    }
    cout << ans << "\n";
  }
  return 0;
}
