#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N];
void solve() {
  int n;
  cin >> n;
  string str;
  cin >> str;
  if (n == 1) {
    if (str[0] == 'a')
      cout << 0 << "\n";
    else
      cout << 1 << "\n";
    return;
  }
  int l = 0, r = n - 1;
  int ans = 0;
  for (char c = 'a'; c <= 'z'; c = (char)(c + 1)) {
    if (l == r) {
      if (str[l] != c) ans++;
      break;
    }
    int len = r - l + 1;
    int lcnt = 0, rcnt = 0;
    for (int i = l; i < len / 2; i++)
      if (str[i] == c) lcnt++;
    for (int i = len / 2; i <= r; i++)
      if (str[i] == c) rcnt++;
    if (lcnt >= rcnt) {
      if (lcnt <= (len / 2)) ans += (len / 2) - lcnt;
      l += len / 2;
    } else {
      if (rcnt <= (len / 2)) ans += (len / 2) - rcnt;
      r -= (len / 2);
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
}
