#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using ull = unsigned long long;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0, r = n - 1;
    int pos = 0, ans = 0;
    while (l < r) {
      int cnt = 0;
      int k1 = 0, k2 = 0;
      while (cnt < (r - l + 1) / 2) {
        if (s[l + cnt] != (char)(pos + 'a')) k1++;
        if (s[r - cnt] != (char)(pos + 'a')) k2++;
        cnt++;
      }
      if (k1 <= k2) {
        ans += k1;
        l += (r - l + 1) / 2;
      } else {
        ans += k2;
        r -= (r - l + 1) / 2;
      }
      pos++;
    }
    if (s[l] != (char)(pos + 'a')) ans++;
    cout << ans << endl;
  }
  return 0;
}
