#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long power(long long a, long long b, long long modi) {
  a %= modi;
  long long res = 1;
  while (b) {
    if (b % 2) {
      res = (res * a) % modi;
    }
    b /= 2;
    a = (a * a) % modi;
  }
  return res;
}
int mini(string s, char ch) {
  int a = 0;
  int b = 0;
  int l = s.length();
  if (l == 1) {
    if (s[0] != ch) return 1;
    return 0;
  }
  for (int i = 0; i < l / 2; i++)
    if (s[i] != ch) a++;
  for (int i = l / 2; i < l; i++)
    if (s[i] != ch) b++;
  int o1 = a + mini(s.substr(l / 2), ch + 1);
  int o2 = b + mini(s.substr(0, l / 2), ch + 1);
  return min(o1, o2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int l;
    cin >> l;
    string s;
    cin >> s;
    cout << mini(s, 'a') << '\n';
  }
  return 0;
}
