#include <bits/stdc++.h>
using namespace std;
int i, n, t, x, y;
string s;
int main() {
  for (cin >> t; t--;) {
    cin >> n >> s;
    for (i = x = y = 0; ++i < n;) {
      if (s[i - 1] + s[i] < 97) x++;
      if (s[i - 1] + s[i] > 97) y++;
    }
    cout << max(x, y) << endl;
  }
}
