#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int calc(const string &s, char c) {
  if (s.size() == 1) return s[0] != c;
  int mid = s.size() / 2;
  int l = calc(string(s.begin(), s.begin() + mid), c + 1);
  l += s.size() / 2 - count(s.begin() + mid, s.end(), c);
  int r = calc(string(s.begin() + mid, s.end()), c + 1);
  r += s.size() / 2 - count(s.begin(), s.begin() + mid, c);
  return min(l, r);
}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  cout << calc(s, 'a') << "\n";
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
