#include <bits/stdc++.h>
using namespace std;
int solve(string s, char c) {
  if ((int)s.size() == 1) {
    return s[0] != c;
  }
  int mid = (int)s.size() / 2;
  int cntl = solve(string(s.begin(), s.begin() + mid), c + 1);
  cntl += (int)s.size() / 2 - count(s.begin() + mid, s.end(), c);
  int cntr = solve(string(s.begin() + mid, s.end()), c + 1);
  cntr += (int)s.size() / 2 - count(s.begin(), s.begin() + mid, c);
  return min(cntl, cntr);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    string s;
    cin >> n >> s;
    cout << solve(s, 'a') << "\n";
  }
}
