#include <bits/stdc++.h>
using namespace std;
long long int t, n;
string s;
long long int F(string s, char c) {
  if (s.length() == 1) {
    if (s[0] == c) {
      return 0;
    }
    return 1;
  }
  long long int one = 0, two = 0;
  long long int n = s.length();
  for (long long int i = 0; i < n; i++) {
    if (i < n / 2) {
      if (s[i] == c) {
        one++;
      }
    } else {
      if (s[i] == c) {
        two++;
      }
    }
  }
  long long int left = F(s.substr(0, n / 2), c + 1);
  long long int right = F(s.substr(n / 2, n), c + 1);
  return min((n / 2) - one + right, (n / 2) - two + left);
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> s;
    cout << F(s, 'a');
    cout << "\n";
  }
  return 0;
}
