#include <bits/stdc++.h>
using namespace std;
int goodComplexity(string s, char c) {
  int len = s.length();
  if (len == 1) return c != s[0];
  int scoreL = 0, scoreR = 0;
  for (int i = 0; i < len; i++) {
    if (c == s[i]) {
      scoreL += i < len / 2;
      scoreR += i >= len / 2;
    }
  }
  if (scoreL == scoreR) {
    int a =
        (len / 2) - scoreL + goodComplexity(s.substr(len / 2, len / 2), c + 1);
    int b = (len / 2) - scoreR + goodComplexity(s.substr(0, len / 2), c + 1);
    if (a < b)
      return a;
    else
      return b;
  }
  if (scoreL > scoreR) {
    return (len / 2) - scoreL +
           goodComplexity(s.substr(len / 2, len / 2), c + 1);
  } else {
    return (len / 2) - scoreR + goodComplexity(s.substr(0, len / 2), c + 1);
  }
}
int main() {
  long t;
  cin >> t;
  while (t--) {
    int tmp;
    cin >> tmp;
    string s;
    cin >> s;
    cout << goodComplexity(s, 'a') << endl;
  }
  return 0;
}
