#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  ;
  int l = 0, h = n;
  int ans = 0;
  char ch = 'a';
  while (l + 1 < h) {
    int mid = (l + h) / 2;
    int cntl = 0, cnth = 0;
    for (int i = l; i < mid; ++i) {
      if (ch == s[i]) ++cntl;
    }
    for (int i = mid; i < h; ++i) {
      if (ch == s[i]) ++cnth;
    }
    if (cntl < cnth) {
      ans += (mid - l - cnth);
      h = mid;
    } else {
      ans += (mid - l - cntl);
      l = mid;
    }
    ++ch;
  }
  if (s[l] != ch) ++ans;
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int ___T;
  cin >> ___T;
  while (___T--) solve();
  cout << flush;
}
