#include <bits/stdc++.h>
using namespace std;
string s;
vector<vector<long long int>> A;
long long int fn(long long int l, long long int r, char x, long long int ld,
                 long long int rd) {
  if (l == r) {
    long long int a = 0, b = 0;
    if (s[l] != x) a++;
    if (s[ld] != x + 1) a++;
    if (s[l] != x + 1) b++;
    if (s[ld] != x) b++;
    return (min(a, b));
  }
  long long int coun;
  if (l != 0)
    coun = A[r][x - 97] - A[l - 1][x - 97];
  else
    coun = A[r][x - 97];
  return (coun + min(fn(ld, (ld + rd) / 2, x + 1, ((ld + rd) / 2) + 1, rd),
                     fn(((ld + rd) / 2) + 1, rd, x + 1, ld, (ld + rd) / 2)));
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  long long int t, i, j, n;
  cin >> t;
  while (t--) {
    cin >> n >> s;
    vector<long long int> temp(26, 1);
    A.clear();
    for (i = 0; i < n; i++) {
      A.push_back(temp);
    }
    if (n == 1) {
      long long int ans = 0;
      if (s[0] != 'a') ans++;
      cout << ans << "\n";
      continue;
    }
    for (i = 0; i < n; i++) {
      A[i][s[i] - 97] = 0;
    }
    for (j = 0; j < 26; j++) {
      for (i = 1; i < n; i++) {
        A[i][j] += A[i - 1][j];
      }
    }
    cout << min(fn(0, (n / 2) - 1, 'a', (n / 2), n - 1),
                fn((n / 2), n - 1, 'a', 0, (n / 2) - 1))
         << "\n";
  }
  return (0);
}
