#include <bits/stdc++.h>
using namespace std;
int half2(string s, char st) {
  string sop = "abcdefghijklmnopqrstuvwxyz";
  int stai = sop.find(st);
  int l = s.length();
  int n_c = l / 2 + 1;
  int f_h = 0, s_h = 0;
  string comad = sop.substr(stai, n_c);
  for (int i = 0; i < l / 2; i++) {
    if (comad.find(s[i]) != string::npos) {
      f_h++;
    }
  }
  for (int i = l / 2; i < l; i++) {
    if (comad.find(s[i]) != string::npos) {
      s_h++;
    }
  }
  if (f_h > s_h) {
    return 1;
  } else {
    return 0;
  }
}
int recursion(string s, int c, char st) {
  if (s.length() == 1) {
    if (s[0] == st) {
      return c;
    } else {
      return c + 1;
    }
  }
  int co = c;
  int l = s.length();
  int init = 0, last = 0;
  int half1 = half2(s, st);
  for (int i = 0; i < l; i++) {
    if (s[i] == st) {
      if (i < l / 2) {
        init++;
      } else {
        last++;
      }
    }
  }
  int f = 0;
  if (init == last) {
    f = half1;
  } else if (init > last) {
    f = 0;
  } else {
    f = 1;
  }
  if (f == 0) {
    co += l / 2 - init;
    return recursion(s.substr(l / 2, l / 2), co, st + 1);
  } else {
    co += l / 2 - last;
    return recursion(s.substr(0, l / 2), co, st + 1);
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, count = 0;
    cin >> n;
    string s;
    cin >> s;
    count = recursion(s, 0, 'a');
    cout << count << endl;
  }
}
