#include <bits/stdc++.h>
using namespace std;
const long long INF64 = 1e18;
clock_t time_p = clock();
void time() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
void doc() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool isprime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void solve() {
  long long cnt = 0, n, k, i;
  cin >> n >> k;
  vector<long long> a;
  string s;
  cin >> s;
  long long ans = 0;
  if (n == 1 and k == 1 and s == "0") {
    cout << "1\n";
    return;
  }
  if (n == 1 and k == 1 and s == "1") {
    cout << "0\n";
    return;
  }
  long long zero = 0, one = 0;
  for (char z : s)
    if (z == '0')
      zero++;
    else
      one++;
  if (zero == n) {
    cout << (n + k) / (k + 1) << '\n';
    return;
  }
  zero = 0;
  for (i = 0; i < n; i++)
    if (s[i] == '1') {
      one--;
      break;
    } else
      zero++;
  ans += (zero / (k + 1));
  i++;
  zero = 0;
  while (one > 0) {
    if (s[i] == '0')
      zero++;
    else {
      ans += (zero + 1) / (k + 1) - 1;
      zero = 0;
      one--;
    }
    i++;
  }
  ans += (n - i) / (k + 1);
  cout << ans << '\n';
}
int main() {
  fast();
  long long t;
  cin >> t;
  while (t--) solve();
}
