#include <bits/stdc++.h>
constexpr auto pi = 3.141592653;
constexpr auto mod = 1000000007;
using namespace std;
int n, t;
string s;
int change(string s, char c) {
  if (s.size() == 1) {
    return s[0] != c;
  }
  int mid = s.size() / 2;
  int right = change(string(s.begin(), s.begin() + mid), c + 1);
  right += s.size() / 2 - count(s.begin() + mid, s.end(), c);
  int left = change(string(s.begin() + mid, s.end()), c + 1);
  left += s.size() / 2 - count(s.begin(), s.begin() + mid, c);
  return min(right, left);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> s;
    cout << change(s, 'a') << "\n";
    s.clear();
  }
  return 0;
}
