#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    long long int z = 0;
    char w = 'a';
    while (s.length() != 0) {
      if (s.length() == 1) {
        if (s[0] != w) z++;
        break;
      }
      long long int p = 0, q = 0;
      long long int u = 0, v = 0;
      for (int i = 0; i < s.length() / 2; ++i) {
        if (s[i] == w) p++;
        if (s[i] == w + 1) u++;
        if (s[s.length() - 1 - i] == w) q++;
        if (s[s.length() - 1 - i] == w + 1) v++;
      }
      if (p > q) {
        z += s.length() / 2 - p;
        s = s.substr(s.length() / 2, s.length() / 2);
      } else if (p < q) {
        z += s.length() / 2 - q;
        s = s.substr(0, s.length() / 2);
      } else {
        if (u < v) {
          z += s.length() / 2 - p;
          s = s.substr(s.length() / 2, s.length() / 2);
        } else {
          z += s.length() / 2 - q;
          s = s.substr(0, s.length() / 2);
        }
      }
      w++;
    }
    cout << z << "\n";
  }
}
