#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
int f[2];
char s[maxn];
inline void solve() {
  scanf("%d%s", &n, s);
  f[0] = f[1] = 0;
  for (int i = (1); i < (n); ++i) f[s[i] - '0'] += (s[i] == s[i - 1]);
  printf("%d\n", max(f[0], f[1]));
}
int main() {
  int T;
  for (scanf("%d", &T); T--; solve())
    ;
  return 0;
}
