#include <bits/stdc++.h>
using namespace std;
const long long int M = 1000000007;
const long long int N = 998244353;
inline long long int add(long long int a, long long int b, long long int MOD) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
inline long long int sub(long long int a, long long int b, long long int MOD) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
inline long long int mul(long long int a, long long int b, long long int MOD) {
  return (long long int)((long long int)a * b % MOD);
}
long long int fermatInv(long long int x, long long int y, long long int m) {
  if (y == 0) return 1;
  long long int p = fermatInv(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
struct comp {
  template <typename T>
  bool operator()(const T &a, const T &b) {
    if (a.first == b.first)
      return (a.second < b.second);
    else
      return (a.first < b.first);
  }
};
bool mod(const pair<long long int, long long int> &a,
         const pair<long long int, long long int> &b) {
  if (a.first != b.first)
    return (a.first < b.first);
  else
    return (a.second < b.second);
}
void sieve(vector<long long int> &prime) {
  long long int maxN = 1e9;
  vector<bool> pr(maxN + 1, 1);
  for (int i = 2; i * i <= maxN; i++)
    if (pr[i] == 1)
      for (int j = i * i; j <= maxN; j += i) pr[j] = 0;
  for (long long int i = 2; i <= maxN; i++)
    if (pr[i] == 1) prime.push_back(i);
}
bool isValid(long long int j, long long int m) {
  if (j < m) {
    return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long int n, m, i, j, k, num, num1, num2, flag = 0;
    cin >> n >> k;
    string s;
    cin >> s;
    long long int prev = s[0];
    long long int seq = 0;
    long long int o = 0;
    for (i = 0; i < n; i++) {
      if (s[i] == '1') {
        o++;
      }
    }
    if (o == 0) {
      cout << (n - 1) / (k + 1) + 1 << "\n";
    } else if (o == 1) {
      long long int one;
      for (i = 0; i < n; i++) {
        if (s[i] == '1') {
          one = i;
          break;
        }
      }
      cout << (n - 1 - i) / (k + 1) + i / (k + 1) << "\n";
    } else {
      long long int ans = 0;
      vector<long long int> one;
      for (i = 0; i < n; i++) {
        if (s[i] == '1') {
          one.push_back(i);
        }
      }
      ans += (n - 1 - one[one.size() - 1]) / (k + 1) + one[0] / (k + 1);
      prev = one[0];
      for (i = 1; i < one.size(); i++) {
        ans += (one[i] - prev) / (k + 1) - 1;
        prev = one[i];
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
