#include <bits/stdc++.h>
using namespace std;
template <class T, class T1>
int chkmin(T &x, const T1 &y) {
  return x > y ? x = y, 1 : 0;
}
template <class T, class T1>
int chkmax(T &x, const T1 &y) {
  return x < y ? x = y, 1 : 0;
}
long long MAXN = 9223372036854775807, mod = 998244353;
bool comp(pair<long long, pair<long long, long long>> &a,
          pair<long long, pair<long long, long long>> &b) {
  if (a.first == b.first) {
    return a.second.first < b.second.first;
  } else
    return a.first < b.first;
}
bool isprime(long long x) {
  if (x == 1) return false;
  if (x == 2 || x == 3 || x == 5) return true;
  for (long long i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  cin >> T;
  for (long long t = 0; t < T; t++) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    long long c = 0;
    for (long long i = 0; i < n; i++) {
      if (s[i] == s[(i + 1) % n]) c++;
    }
    cout << c / 2 << '\n';
  }
  return 0;
}
