#include <bits/stdc++.h>
using namespace std;
string s;
long long int n;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> s;
    long long int cnt = 0;
    long long int l = 0, r = n - 1;
    char c = 'a';
    while (l <= r) {
      if (l == r) {
        cnt += (s[l] != c);
        break;
      } else {
        long long int bnt[2] = {0, 0};
        long long int mid = (l + r) / 2;
        for (int i = l; i <= r; i++) {
          bnt[i > mid] += (s[i] != c);
        }
        if (bnt[0] <= bnt[1]) {
          cnt += bnt[0];
          l = mid + 1;
        } else {
          cnt += bnt[1];
          r = mid;
        }
        c++;
      }
    }
    cout << cnt;
    cout << endl;
  }
  return 0;
}
