#include <bits/stdc++.h>
using namespace std;
int func(string& s, int i, int j, char to_char) {
  int n = j - i + 1, cnt1 = 0, cnt2 = 0;
  if (n == 1) {
    if (s[i] == to_char)
      return 0;
    else
      return 1;
  }
  cnt1 = func(s, i + n / 2, j, to_char + 1);
  cnt1 += n / 2 - count(s.begin() + i, s.begin() + i + n / 2, to_char);
  cnt2 = func(s, i, (i + n / 2) - 1, to_char + 1);
  cnt2 += n / 2 - count(s.begin() + i + n / 2, s.begin() + j + 1, to_char);
  return min(cnt1, cnt2);
}
int main(int argc, char const* argv[]) {
  int t, n;
  string s;
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> s;
    cout << func(s, 0, n - 1, 'a') << '\n';
  }
  return 0;
}
