#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e9;
void inverse(char& a) {
  if (a == '1')
    a = '0';
  else
    a = '1';
}
void write() {
  int T;
  cin >> T;
  for (int t = 0; t < T; ++t) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int inversions = 0;
    char f = s[0];
    for (int i = 1; i < n; ++i) {
      inverse(f);
      if (s[i] != f) {
        while (s[i] != f && i < n) {
          i++;
          inverse(f);
        }
        inversions++;
      }
    }
    cout << inversions << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  write();
  return 0;
}
