#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000000 + 7;
long long pass(string s, long long u, long long v, char ch) {
  if (v - u == 2) {
    if (s[u] == ch) {
      if (s[u + 1] == ch + 1)
        return 0;
      else
        return 1;
    } else if (s[u + 1] == ch) {
      if (s[u] == ch + 1)
        return 0;
      else
        return 1;
    } else
      return 2;
  }
  long long cnt = 0, cnt1 = 0, len = v - u;
  for (long long i = u; i < u + len / 2; i++)
    if (s[i] != ch) cnt++;
  for (long long i = u + len / 2; i < v; i++)
    if (s[i] != ch) cnt1++;
  if (cnt > cnt1)
    return cnt1 + pass(s, u, v - len / 2, ch + 1);
  else
    return cnt + pass(s, u + len / 2, v, ch + 1);
}
void solve() {
  long long n;
  string s;
  cin >> n >> s;
  if (n == 1) {
    if (s[0] == 'a')
      cout << "0\n";
    else
      cout << "1\n";
  } else
    cout << pass(s, 0, n, 'a') << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
