#include <bits/stdc++.h>
using namespace std;
int f(string s, char ch) {
  if (s.size() == 1) {
    if (s[0] == ch)
      return 0;
    else
      return 1;
  }
  int mid = s.size() / 2;
  int lcnt = s.size() / 2 - count(s.begin() + mid, s.end(), ch);
  lcnt += f(string(s.begin(), s.begin() + mid), ch + 1);
  int rcnt = s.size() / 2 - count(s.begin(), s.begin() + mid, ch);
  rcnt += f(string(s.begin() + mid, s.end()), ch + 1);
  return min(lcnt, rcnt);
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    string s;
    cin >> n >> s;
    cout << f(s, 'a') << endl;
  }
}
