#include <bits/stdc++.h>
using namespace std;
int q, n, k;
string s;
void Ucitaj() {
  cin >> n;
  cin >> s;
}
int IzbrojC(int l, int r, char c) {
  int br = 0;
  for (int i = l; i < r; i++) {
    if (s[i] != c) {
      br++;
    }
  }
  return br;
}
int Resi(int l, int r, int c) {
  if (l + 1 == r) {
    return (s[l] != c);
  }
  int m = (r + l) / 2;
  int br1 = IzbrojC(l, m, c);
  int br2 = IzbrojC(m, r, c);
  return min(br1 + Resi(m, r, c + 1), br2 + Resi(l, m, c + 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> q;
  while (q--) {
    Ucitaj();
    cout << Resi(0, n, 'a') << "\n";
  }
  return 0;
}
