#include <bits/stdc++.h>
using namespace std;
long long res;
void makeGood(char c, string s) {
  long long n = s.size();
  if (n == 1) {
    if (s[0] != c) res++;
    return;
  }
  long long left_freq = 0, right_freq = 0;
  for (long long i = 0; i < n / 2; i++) {
    if (s[i] == c) left_freq++;
  }
  for (long long i = n / 2; i < n; i++) {
    if (s[i] == c) right_freq++;
  }
  if (left_freq >= right_freq) {
    res += n / 2 - left_freq;
    string n_s(s.begin() + n / 2, s.end());
    makeGood(c + 1, n_s);
  } else if (left_freq < right_freq) {
    res += n / 2 - right_freq;
    string n_s(s.begin(), s.end() - n / 2);
    makeGood(c + 1, n_s);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    res = 0;
    long long n;
    string s;
    cin >> n;
    cin >> s;
    makeGood('a', s);
    cout << res << endl;
  }
  return 0;
}
