#include <bits/stdc++.h>
using namespace std;
const long long int linf = (long long)9e18;
const int dx[8] = {0, 0, 1, -1, 1, -1, 1, -1},
          dy[8] = {1, -1, 0, 0, 1, -1, -1, 1};
int solve(string s, char c) {
  if (s.size() == 1) return s[0] != c;
  int mid = s.size() / 2;
  int cntl = solve(string(s.begin() + mid, s.end()), c + 1);
  cntl += s.size() / 2 - count(s.begin(), s.begin() + mid, c);
  int cntr = solve(string(s.begin(), s.begin() + mid), c + 1);
  cntr += s.size() / 2 - count(s.begin() + mid, s.end(), c);
  return min(cntr, cntl);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  char c = 'a';
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    cout << solve(s, 'a') << endl;
  }
  return 0;
}
