#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int dfs(const string s, const char c, const int x) {
  if (s.size() == 1) {
    if (s[0] != c) return x + 1;
    return x;
  }
  int h = s.size() / 2;
  int r1 = x;
  for (int i = (0); i < (h); i++)
    if (s[i] != c) r1++;
  r1 = dfs(s.substr(h), c + 1, r1);
  int r2 = x;
  for (int i = (h); i < (s.size()); i++)
    if (s[i] != c) r2++;
  r2 = dfs(s.substr(0, h), c + 1, r2);
  return min(r1, r2);
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  for (int _ = (0); _ < (t); _++) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    cout << (dfs(s, 'a', 0)) << '\n';
  }
  return 0;
}
