#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long temp = a * b;
  temp /= gcd(max(a, b), min(a, b));
  return temp;
}
int checkgood(string s, char c) {
  if (s.length() == 1) return s[0] != c;
  int mid = s.length() / 2;
  int count1 = checkgood(string(s.begin(), s.begin() + mid), c + 1);
  count1 += s.length() / 2 - count(s.begin() + mid, s.end(), c);
  int count2 = checkgood(string(s.begin() + mid, s.end()), c + 1);
  count2 += s.length() / 2 - count(s.begin(), s.begin() + mid, c);
  return min(count1, count2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    cout << checkgood(s, 'a') << "\n";
  }
}
