#include <bits/stdc++.h>
using namespace std;
const int size1 = 1005;
const int size2 = 55;
const long long mod = 1e9 + 7;
long long n, k;
long long func(long long val) {
  if (val <= 0) return 0;
  long long ans = val / (k + 1);
  if (val % (k + 1) != 0) ans++;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    string s;
    cin >> s;
    vector<long long> vi;
    long long cnt = 0;
    long long st = -1;
    long long ans = 0;
    if (s[0] == '0') {
      st = 0;
      cnt = 1;
    }
    for (long long i = 1; i < n; i++) {
      if (s[i] == s[i - 1]) {
        if (s[i] == '1') continue;
        if (s[i] == '0') cnt++;
      } else {
        if (s[i] == '0') {
          cnt = 1;
          st = i;
          continue;
        }
        if (st == 0) {
          ans += func(cnt - k);
        } else {
          ans += func(cnt - 2 * k);
        }
        cnt = 0;
      }
    }
    if (cnt > 0 and st != 0)
      ans += func(cnt - k);
    else if (cnt > 0 and st == 0)
      ans += func(cnt);
    cout << ans << endl;
  }
}
