#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll power(ll x, ll y);
const ll MOD = 1000000007;
map<pair<int, int>, int> dp;
int n;
string s;
vector<pair<int, int> > temp;
int cgood(int l, int r, char c) {
  if (c > 'z') return 1e6;
  int N = r - l;
  if (N == 2) {
    int a = s[l] == c || s[l + 1] == c;
    int b = s[l] == c + 1 || s[l + 1] == c + 1;
    return 2 - a - b;
  }
  if (N == 1) return s[l] != c;
  if (dp.count(make_pair(l, r))) return dp[make_pair(l, r)];
  int L = 0, R = 0;
  for (int i = l; i < r / 2; i++) L += s[i] == c;
  for (int i = r / 2; i < r; i++) R += s[i] == c;
  int resl = N / 2 - L + cgood(r - N / 2, r, c + 1);
  int resr = N / 2 - R + cgood(l, r - N / 2, c + 1);
  return dp[make_pair(l, r)] = min(resl, resr);
}
int agood(int l, int r) {
  int res = 0;
  for (int i = l; i < r; i++) res += s[i] != 'a';
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    dp.clear();
    cin >> n >> s;
    int ans;
    if (n == 1)
      ans = s[0] != 'a';
    else
      ans = min(agood(0, n / 2) + cgood(n / 2, n, 'b'),
                agood(n / 2, n) + cgood(0, n / 2, 'b'));
    cout << ans << "\n";
  }
}
ll power(ll x, ll y) {
  ll res = 1;
  x %= MOD;
  while (y > 0) {
    if (y & 1) res = (res * x) % MOD;
    y = y >> 1, x = (x * x) % MOD;
  }
  return res;
}
