#include <bits/stdc++.h>
using namespace std;
void fileIO() {}
bool sortbysecdesc(const pair<long long, long long> &a,
                   const pair<long long, long long> &b) {
  return a.second > b.second;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  fileIO();
  long long T;
  T = 1;
  cin >> T;
  while (T--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    vector<long long> a(n), ideal(n), ideal2(n);
    for (long long i = 0; i < n; i++) {
      a[i] = (long long)(s[i] - '0');
    }
    long long start = a[0];
    for (long long i = 0; i < n; i++) {
      ideal[i] = start;
      start = 1 - start;
    }
    start = 1 - a[0];
    for (long long i = 0; i < n; i++) {
      ideal2[i] = start;
      start = 1 - start;
    }
    long long flips = 0;
    long long ans1 = 0, ans2 = 0;
    for (long long i = 0; i < n;) {
      if (ideal[i] != a[i]) {
        ans1++;
        while (i < n && a[i] != ideal[i]) i++;
      } else {
        i++;
      }
    }
    for (long long i = 0; i < n;) {
      if (ideal2[i] != a[i]) {
        ans2++;
        while (i < n && a[i] != ideal2[i]) i++;
      } else {
        i++;
      }
    }
    cout << min(ans1, ans2) << "\n";
  }
  return 0;
}
