#include <bits/stdc++.h>
using namespace std;
int cal(string str, char ch) {
  if (str.size() == 1) return str[0] != ch;
  int mid = str.size() / 2;
  int cntl = cal(string(str.begin(), str.begin() + mid), ch + 1);
  cntl += str.size() / 2 - count(str.begin() + mid, str.end(), ch);
  int cntr = cal(string(str.begin() + mid, str.end()), ch + 1);
  cntr += str.size() / 2 - count(str.begin(), str.begin() + mid, ch);
  return min(cntl, cntr);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string str;
    cin >> str;
    int l = 0, r = n - 1;
    int ans = cal(str, 'a');
    cout << ans << endl;
  }
  return 0;
}
