#include <bits/stdc++.h>
using namespace std;
int cost(string s, char a) {
  if (s.length() == 1) {
    if (s[0] == a) {
      return 0;
    } else {
      return 1;
    }
  }
  int n = s.length();
  int sm1 = 0;
  int sm2 = 0;
  string s1 = "";
  string s2 = "";
  for (int i = 0; i < n; i++) {
    if (i < n / 2) {
      if (s[i] != a) {
        sm1++;
      }
      s1 += s[i];
    } else {
      if (s[i] != a) {
        sm2++;
      }
      s2 += s[i];
    }
  }
  char nc = (a - 'a') + 1 + 'a';
  return min(sm1 + cost(s2, nc), sm2 + cost(s1, nc));
}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  cout << cost(s, 'a') << '\n';
}
void querySolve() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  querySolve();
}
