#include <bits/stdc++.h>
using namespace std;
using num = long long;
int counts(string& s, char c) { return count(s.begin(), s.end(), c); }
int main() {
  int t;
  scanf("%d", &t);
  for (int caseCounter = 1; caseCounter <= t; ++caseCounter) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string a, b;
    int ans = 0;
    char c = 'a';
    char end_char = c + round(log(n) / log(2));
    if (s.size() == 1 && s[0] != 'a') {
      ans = 1;
      goto ShowAnswer;
    }
    while (n > 1) {
      a = s.substr(0, n / 2);
      b = s.substr(n / 2, n);
      if (counts(b, c) > counts(a, c)) {
        swap(a, b);
      } else if (a.find(c) == string::npos &&
                 counts(a, c + 1) > counts(b, c + 1)) {
        swap(a, b);
      } else if (a.find(end_char) != string::npos) {
        swap(a, b);
      }
      for (int i = 0; i < a.length(); ++i) {
        if (a[i] != c) {
          ans++;
          a[i] = c;
        }
      }
      n = a.length();
      s = b;
      c++;
    }
    if (a.size() == 1 && b.size() == 1 && abs(a[0] - b[0]) != 1) {
      ans += 1;
    }
  ShowAnswer:
    cout << ans << endl;
  }
  return 0;
}
