#include <bits/stdc++.h>
using namespace std;
int fun(string s, int n, int ascii) {
  if (ascii > 122) ascii = 97;
  char c = ascii;
  if (n == 1) {
    if (s[n - 1] == c)
      return 0;
    else
      return 1;
  } else {
    int firsthalf = 0;
    int secondhalf = 0;
    for (int i = 0; i < n / 2; i++) {
      if (s[i] == c) firsthalf++;
    }
    for (int i = n / 2; i < n; i++) {
      if (s[i] == c) secondhalf++;
    }
    if (firsthalf > secondhalf) {
      string snew = "";
      for (int i = n / 2; i < n; i++) {
        snew += s[i];
      }
      return n / 2 - firsthalf + fun(snew, n / 2, ascii + 1);
    } else if (firsthalf < secondhalf) {
      string snew = "";
      for (int i = 0; i < n / 2; i++) {
        snew += s[i];
      }
      return n / 2 - secondhalf + fun(snew, n / 2, ascii + 1);
    } else {
      string snew = "";
      for (int i = n / 2; i < n; i++) {
        snew += s[i];
      }
      string snew2 = "";
      for (int i = 0; i < n / 2; i++) {
        snew2 += s[i];
      }
      return min(n / 2 - firsthalf + fun(snew, n / 2, ascii + 1),
                 n / 2 - secondhalf + fun(snew2, n / 2, ascii + 1));
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    string s;
    cin >> n >> s;
    int x = fun(s, n, 97);
    cout << x << endl;
  }
}
