#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;
void fin() {}
const bool flag = 1;
void ma1n() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = -1;
  s += s.back();
  int cnt = 0;
  for (int i = 0; i <= n; ++i) {
    if (i && s[i] != s[i - 1]) {
      cnt++;
    } else {
      ans++;
      cnt = 1;
    }
  }
  cout << ans / 2 << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr), fin();
  int ts = 1;
  if (flag) {
    cin >> ts;
  }
  while (ts--) {
    ma1n();
  }
  return 0;
}
