#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int cnt(string s, int i, int j, char ch) {
  int c1 = 0, c2 = 0, maxcnt = 0;
  if (j - i == 1) {
    if (s[i] == ch) maxcnt++;
    return maxcnt;
  } else if (j - i == 2) {
    if (s[i] == ch) {
      ch = ch + 1;
      maxcnt++;
      if (s[i + 1] == ch) maxcnt++;
    } else if (s[i + 1] == ch) {
      ch = ch + 1;
      maxcnt++;
      if (s[i] == ch) maxcnt++;
    }
    return maxcnt;
  } else if (j - i > 2) {
    for (int k = i; k < (j + i) / 2; k++) {
      if (s[k] == ch) c1++;
    }
    for (int k = (j + i) / 2; k < j; k++) {
      if (s[k] == ch) c2++;
    }
    maxcnt += max(c1, c2);
    return (c1 >= c2) ? (maxcnt + cnt(s, (j + i) / 2, j, ch + 1))
                      : (maxcnt + cnt(s, i, (j + i) / 2, ch + 1));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    cout << n - cnt(s, 0, n, 'a') << endl;
  }
}
