#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long ans_1 = 0, ans_2 = 0, cnt = 1, tmp = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1]) {
      cnt++;
    } else {
      if (tmp)
        ans_1 += cnt - 1;
      else
        ans_2 += cnt - 1;
      tmp = (tmp + 1) % 2;
      cnt = 1;
    }
  }
  if (tmp)
    ans_1 += cnt - 1;
  else
    ans_2 += cnt - 1;
  cout << max(ans_1, ans_2);
}
signed main() {
  signed T;
  cin >> T;
  while (T--) {
    solve();
    cout << '\n';
  }
  return 0;
}
