#include <bits/stdc++.h>
using namespace std;
string a;
int f[200005][30];
int t, n;
void nhap() {
  ios_base::sync_with_stdio(0);
  cin >> t;
}
int calc1(int l, int r, char x) {
  return (r - l + 1) - f[r + 1][x - 'a'] + f[l][x - 'a'];
}
int calc2(int l, int r, char x) {
  if (r > l)
    return min(calc1(l, l + (r - l + 1) / 2 - 1, x) +
                   calc2(l + (r - l + 1) / 2, r, x + 1),
               calc1(l + (r - l + 1) / 2, r, x) +
                   calc2(l, l + (r - l + 1) / 2 - 1, x + 1));
  else if (a[l] != x)
    return 1;
  else
    return 0;
}
void xl() {
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= 26; ++j) f[i][j] = 0;
  for (int i = 0; i < a.length(); ++i)
    for (int j = 0; j <= 26; ++j) {
      f[i + 1][j] = f[i][j];
      if (a[i] - 'a' == j) ++f[i + 1][j];
    }
  int res = min(calc1(0, n / 2 - 1, 'a') + calc2(n / 2, n - 1, 'b'),
                calc1(n / 2, n - 1, 'a') + calc2(0, n / 2 - 1, 'b'));
  if (n != 1)
    cout << res << '\n';
  else if (a[0] != 'a')
    cout << "1" << '\n';
  else
    cout << "0" << '\n';
}
int main() {
  nhap();
  for (int ii = 1; ii <= t; ++ii) {
    cin >> n;
    cin >> a;
    xl();
  }
  return 0;
}
