#include <bits/stdc++.h>
using namespace std;
int calc(const string &s, char c) {
  if (s.size() == 1)
    if (s[0] == c)
      return 0;
    else
      return 1;
  int mid = s.size() / 2;
  int cntl = calc(string(s.begin(), s.begin() + mid), c + 1);
  cntl += mid - count(s.begin() + mid, s.end(), c);
  int cntr = calc(string(s.begin() + mid, s.end()), c + 1);
  cntr += mid - count(s.begin(), s.begin() + mid, c);
  return min(cntl, cntr);
}
void solve() {
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  cout << calc(s, 'a') << endl;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
