#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t-- != 0) {
    long long int n, k;
    cin >> n >> k;
    string s;
    getline(cin >> ws, s);
    long long int a[n];
    for (long long int i = 0; i < n; i++) {
      a[i] = (long long int)s.at(i) - 48;
    }
    long long int b[n];
    long long int c = 0;
    for (long long int i = 0; i < n; i++) {
      if (a[i] == 1) c++;
      b[i] = c;
    }
    long long int m = 0;
    for (long long int i = 0; i < n; i++) {
      if (a[i] == 1)
        i = i + k;
      else {
        if ((i + k) < n) {
          if (b[i] == b[i + k]) {
            m++;
            i = i + k;
          }
        } else {
          if (b[i] == b[n - 1]) {
            m++;
            i = i + k;
          }
        }
      }
    }
    cout << m << "\n";
  }
  return 0;
}
