#include <bits/stdc++.h>
using namespace std;
int helper(int arr[], int no, int k) {
  int right[no];
  int left[no];
  int distance = no + 10;
  for (int i = no - 1; i >= 0; i--) {
    if (arr[i] == 0)
      right[i] = (++distance);
    else
      distance = 0;
  }
  int ans = 0;
  distance = no + 10;
  for (int i = 0; i < no; i++) {
    if (arr[i] == 0) {
      left[i] = (++distance);
      if (left[i] > k && right[i] > k) {
        ans++;
        arr[i] = 1;
        distance = 0;
      }
    } else
      distance = 0;
  }
  return ans;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int no, k;
    cin >> no >> k;
    string s;
    cin >> s;
    int arr[no];
    for (int i = 0; i < no; i++) {
      if (s[i] == '0')
        arr[i] = 0;
      else
        arr[i] = 1;
    }
    cout << helper(arr, no, k) << endl;
  }
  return 0;
}
