#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
map<tuple<int, int, char>, int> cache;
string str;
int count(int begin, int end, char symbol) {
  int res = 0;
  for (int i = begin; i < end; i++) {
    if (str[i] != symbol) res++;
  }
  return res;
}
long long calc(int begin, int end, char symb) {
  int res = INT_MAX;
  if (end - begin == 2) {
    if (str[begin] == symb && str[begin + 1] == symb + 1 ||
        str[begin + 1] == symb && str[begin] == symb + 1)
      return 0;
    else if (str[begin] != symb && str[begin + 1] != symb &&
             str[begin] != symb + 1 && str[begin + 1] != symb + 1)
      return 2;
    else
      return 1;
  }
  if (end - begin == 1) {
    if (str[begin] == symb)
      return 0;
    else
      return 1;
  }
  tuple<int, int, char> key = {begin, end, symb};
  if (cache.count(key) == 1) {
    return cache[key];
  }
  int mid = begin + (end - begin) / 2;
  int change_left = count(begin, mid, symb);
  int change_right = count(mid, end, symb);
  int first = change_left + calc(mid, end, symb + 1);
  int second = change_right + calc(begin, mid, symb + 1);
  res = min(first, second);
  return cache[key] = res;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cache.clear();
    int n;
    cin >> n;
    cin >> str;
    long long res = calc(0, str.size(), 'a');
    cout << res << endl;
  }
}
