#include <bits/stdc++.h>
using namespace std;
string makeGood(string s, char ch) {
  int n = (int)s.size();
  string ans = "";
  if (n == 1) {
    ans += ch;
    return ans;
  }
  char temp = ch;
  string first = s.substr(0, n / 2), second = s.substr(n / 2, n / 2);
  bool secondLetter = false;
  int firstCount = count(begin(first), end(first), temp),
      secondCount = count(begin(second), end(second), temp);
  if (firstCount == secondCount) {
    secondLetter = true;
    firstCount = count(begin(first), end(first), temp + 1),
    secondCount = count(begin(second), end(second), temp + 1);
  }
  if (secondLetter) {
    if (firstCount == secondCount) {
      string ans1 = "", ans2 = "";
      ans1 += makeGood(first, ch + 1);
      ans1.append(n / 2, ch);
      ans2.append(n / 2, ch);
      ans2 += makeGood(second, ch + 1);
      int diff1 = 0, diff2 = 0;
      for (int i = 0; i < n; ++i) {
        if (s[i] != ans1[i]) diff1++;
        if (s[i] != ans2[i]) diff2++;
      }
      ans = ((diff1 > diff2) ? ans2 : ans1);
    } else if (firstCount > secondCount) {
      ans += makeGood(first, ch + 1);
      ans.append(n / 2, ch);
    } else {
      ans.append(n / 2, ch);
      ans += makeGood(second, ch + 1);
    }
  } else {
    if (firstCount == secondCount) {
      string ans1 = "", ans2 = "";
      ans1 += makeGood(first, ch + 1);
      ans1.append(n / 2, ch);
      ans2.append(n / 2, ch);
      ans2 += makeGood(second, ch + 1);
      int diff1 = 0, diff2 = 0;
      for (int i = 0; i < n; ++i) {
        if (s[i] != ans1[i]) diff1++;
        if (s[i] != ans2[i]) diff2++;
      }
      ans = ((diff1 > diff2) ? ans2 : ans1);
    } else if (firstCount > secondCount) {
      ans.append(n / 2, ch);
      ans += makeGood(second, ch + 1);
    } else {
      ans += makeGood(first, ch + 1);
      ans.append(n / 2, ch);
    }
  }
  return ans;
}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string ans = makeGood(s, 'a');
  int count = 0;
  for (int i = 0; i < n; ++i)
    if (ans[i] != s[i]) count++;
  cout << count << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
