#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, ans = 0;
    string s;
    cin >> n >> k >> s;
    for (int i = 0; i < n; ++i) {
      if (s[i] == '1') {
        for (int j = i + 1; j < min(i + k + 1, n); ++j) {
          s[j] = 'x';
        }
      }
    }
    reverse(s.begin(), s.end());
    for (int i = 0; i < n; ++i) {
      if (s[i] == '1') {
        for (int j = i + 1; j < min(i + k + 1, n); ++j) {
          s[j] = 'x';
        }
      }
    }
    reverse(s.begin(), s.end());
    for (int i = 0; i < n; ++i) {
      if (s[i] == '0') {
        ++ans;
        i = i + k;
      }
    }
    cout << ans << endl;
  }
}
