#include <bits/stdc++.h>
using namespace std;
inline long long int sbt(long long int x) { return __builtin_popcount(x); }
inline long long int mul(long long int a, long long int b,
                         long long int m = 1000000007) {
  return (a * b) % m;
}
inline long long int add(long long int a, long long int b,
                         long long int m = 1000000007) {
  return (a + b) % m;
}
inline long long int sub(long long int a, long long int b,
                         long long int m = 1000000007) {
  return (a - b + m) % m;
}
long long int solve(string s, long long int n, char c) {
  if (n <= 0) return 0;
  long long int moves = 0;
  for (long long int(i) = (0); (i) < (n / 2); (i)++) {
    if (s[i] != c) {
      moves++;
    }
  }
  c++;
  string gg = s.substr(n / 2);
  string tmp = gg;
  reverse((tmp).begin(), (tmp).end());
  return moves + min(solve(gg, n / 2, c), solve(tmp, n / 2, c));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    string tmp = s;
    reverse((tmp).begin(), (tmp).end());
    long long int moves = min(solve(s, n, 'a'), solve(tmp, n, 'a'));
    cout << moves + 1 << "\n";
  }
  return 0;
}
