#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
const long long int INF = 1e18;
const long long int MOD = 1e9 + 7;
inline long long int mod_pow(long long int a, long long int b) {
  long long int res = 1;
  a %= MOD;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
inline long long int mod_inv(long long int a, long long int b) {
  return mod_pow(a, MOD - 2);
}
string s;
long long int n;
long long int good_str(long long int l, long long int r, char ch) {
  if (l == r - 1) return (s[l] != ch);
  long long int a = 0, b = 0, mid;
  mid = (l + r) / 2;
  for (long long int i = l; i < mid; ++i) a += (s[i] != ch);
  for (long long int i = mid; i < r; ++i) b += (s[i] != ch);
  a += good_str(mid, r, char(ch + 1));
  b += good_str(l, mid, char(ch + 1));
  return min(a, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int TT = 1;
  cin >> TT;
  while (TT--) {
    cin >> n;
    cout << s;
    cin >> s;
    cout << good_str(0, n, 'a') << '\n';
  }
  return 0;
}
