#include <bits/stdc++.h>
using namespace std;
int co = 0;
char target = 'a';
void good(string s) {
  if (s.size() == 1) {
    if (s[0] != target) co++;
    return;
  }
  int first_index = s.find(target);
  int last_index = first_index + count((s).begin(), (s).end(), target);
  int first_judge = first_index - s.size() / 2;
  if (first_judge < 0) first_judge *= -1;
  int last_judge = last_index - s.size() / 2;
  if (last_judge < 0) last_judge *= -1;
  bool is_left = first_judge >= last_judge ? true : false;
  if (is_left) {
    for (int i = 0; i < s.size() / 2; i++) {
      if (s[i] != target) {
        s[i] = target;
        co++;
      }
    }
    target = static_cast<char>(target + 1);
    good(s.substr(s.size() / 2));
  } else {
    for (int i = s.size() / 2; i < s.size(); i++) {
      if (s[i] != target) {
        s[i] = target;
        co++;
      }
    }
    target = static_cast<char>(target + 1);
    good(s.substr(0, s.size() / 2));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    target = 'a';
    co = 0;
    string s;
    cin >> s;
    good(s);
    cout << co << '\n';
  }
}
