#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, ans;
string s;
void calc(string t, int c, int sum) {
  if ((int)((t).size()) == 1) {
    if (t[0] != char(c + 'a')) sum++;
    ans = min(ans, sum);
    return;
  }
  int x = 0, y = 0;
  string a = "", b = "";
  for (int i = 0; i < (int)((t).size()) / 2; i++) {
    x += t[i] == char(c + 'a');
    a += t[i];
  }
  for (int i = (int)((t).size()) / 2; i < (int)((t).size()); ++i) {
    y += t[i] == char(c + 'a');
    b += t[i];
  }
  x = (int)((t).size()) / 2 - x;
  y = (int)((t).size()) / 2 - y;
  calc(b, c + 1, sum + x);
  calc(a, c + 1, sum + y);
}
void solve() {
  cin >> n >> s;
  ans = 1e9;
  calc(s, 0, 0);
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  cin >> T;
  while (T--) solve();
}
