#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int M = 17 + 5;
const int W = 1000 + 5;
const int OO = 2e9;
const int mod = 1e9 + 7;
int t, n, k, ans, nxt[N], lst, b;
string second;
void init() {
  lst = OO;
  ans = b = 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> k >> second;
    init();
    for (int i = n - 1; i >= 0; --i) {
      if (second[i] == '1') lst = i;
      nxt[i] = lst;
    }
    for (int i = 0; i < n; ++i) {
      if (second[i] == '1') b = i + k + 1;
      if (second[i] == '0' && i >= b && i + k < nxt[i]) {
        ++ans;
        b = i + k + 1;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
