#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long inf = 1e9 + 7;
long long modexp(long long base, long long power) {
  if (power == 0) return 1;
  if (power & 1) return base * modexp(base, power - 1) % inf;
  return modexp(base * base % inf, power / 2);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pair<long long, long long>> a;
    for (long long i = 0; i < n; i++) {
      if (s[i] - '0' == 1) {
        long long x = i - k - 1;
        long long y = i + k + 1;
        a.push_back({x, y});
      }
    }
    long long last = 0;
    long long ans = 0;
    for (long long i = 0; i < a.size(); i++) {
      if (a[i].first < last) {
        last = a[i].second;
      } else if (a[i].first == last) {
        ans += 1;
        last = a[i].second;
      } else {
        long long x = (a[i].first - last + 1) / (k + 1);
        long long y = (a[i].first - last + 1) % (k + 1);
        if (y != 0)
          ans += (x + 1);
        else
          ans += x;
        last = a[i].second;
      }
    }
    if (last < n - 1) {
      long long x = (n - 1 - last + 1) / (k + 1);
      long long y = (n - 1 - last + 1) % (k + 1);
      if (y != 0)
        ans += (x + 1);
      else
        ans += x;
    } else if (last == n - 1)
      ans += 1;
    cout << ans << endl;
  }
  return 0;
}
