#include <bits/stdc++.h>
using namespace std;
string st;
int countCh(int l, int r, char ch) {
  int ct = 0;
  for (int i = l; i <= r; i++)
    if (st[i] == ch) ct++;
  return ct;
}
int segTree(int l, int r, char ch) {
  if (l == r) {
    if (st[l] == ch)
      return 0;
    else
      return 1;
  }
  int mid = (l + r) >> 1;
  int half = (r - l + 1) / 2;
  int r1 = segTree(l, mid, ch + 1);
  r1 += (half - countCh(mid + 1, r, ch));
  int r2 = segTree(mid + 1, r, ch + 1);
  r2 += (half - countCh(l, mid, ch));
  return min(r1, r2);
}
void solve() {
  int n;
  cin >> n;
  cin >> st;
  cout << segTree(0, n - 1, 'a') << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc = 1;
  cin >> tc;
  for (int i = 1; i <= tc; i++) {
    solve();
  }
  return 0;
}
