#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1.0);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int n, k;
    cin >> n >> k;
    string t;
    string T;
    cin >> t;
    T = t;
    vector<int> pos;
    for (int i = 0; i < t.size(); i++) {
      if (t[i] == '1') pos.push_back(i);
    }
    if (pos.size() == 0) {
      for (int i = 0; i < t.size(); i += (k + 1)) {
        t[i] = '1';
      }
    } else {
      for (int i = 0; i < pos[0] - k; i += (k + 1)) {
        t[i] = '1';
      }
      for (int i = pos.back() + k + 1; i < t.size(); i += (k + 1)) {
        t[i] = '1';
      }
    }
    for (int i = 1; i < pos.size(); i++) {
      for (int j = pos[i - 1] + k + 1; j < pos[i] - k; j += (k + 1)) {
        t[j] = '1';
      }
    }
    int ans = 0;
    for (int i = 0; i < t.size(); i++) {
      if (t[i] != T[i]) ans++;
    }
    cout << ans << "\n";
  }
  return 0;
}
