#include <bits/stdc++.h>
using namespace std;
string a;
int T, n, ans, ans0, tmp, tmp0;
int main() {
  cin >> T;
  while (T--) {
    ans = ans0 = 0;
    cin >> n >> a;
    tmp = tmp0 = 1;
    for (int i = 1; i < n; i++) {
      if (a[i] == '1') {
        if (a[i] == a[i - 1])
          tmp++;
        else
          ans += tmp - 1, tmp = 1;
      }
      if (a[i] == '0') {
        if (a[i] == a[i - 1])
          tmp0++;
        else
          ans0 += tmp0 - 1, tmp0 = 1;
      }
    }
    ans += tmp - 1;
    ans0 += tmp0 - 1;
    cout << max(ans, ans0) << endl;
  }
}
