#include <bits/stdc++.h>
using namespace std;
long long exp(long long x, long long y) {
  x %= 1000000007;
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % 1000000007;
    x = x * x % 1000000007;
    y >>= 1;
  }
  return res;
}
int fact(int n) {
  int res = 1;
  for (int i = 2; i <= n; ++i) res *= i;
  return res;
}
int n;
string s;
int k_string(int k, int l, int r) {
  int cnt = 0;
  for (int i = l; i <= r; ++i) {
    if (s[i] == 'a' + k) continue;
    ++cnt;
  }
  return cnt;
}
int solve(int k, int l, int r) {
  if (r == l)
    if (s[r] == 'a' + k)
      return 0;
    else
      return 1;
  int minimum = 0;
  int l1 = k_string(k, l, l + (r - l + 1) / 2 - 1);
  int r1 = k_string(k, l + (r - l + 1) / 2, r);
  minimum += min(l1, r1);
  if (l1 > r1) {
    minimum += solve(k + 1, l, l + (r - l + 1) / 2 - 1);
  } else {
    minimum += solve(k + 1, l + (r - l + 1) / 2, r);
  }
  return minimum;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> s;
    cout << solve(0, 0, n - 1) << '\n';
  }
  return 0;
}
