#include <bits/stdc++.h>
using namespace std;
const long long zero = 0;
const double PI = 3.14159265358979323846;
void solve() {
  long long n, m, a, b, k;
  string s;
  cin >> n >> s;
  long long ans = 0;
  char ch = 'a';
  s = "#" + s;
  if (n == 1) {
    if (s[1] == ch)
      cout << 0;
    else
      cout << 1;
    return;
  }
  while (n) {
    m = s.size() - 1;
    long long count1 = 0, count2 = 0;
    for (long long i = 1; i <= m / 2; i++)
      if (s[i] == ch) count1++;
    for (long long i = m / 2 + 1; i <= m; i++)
      if (s[i] == ch) count2++;
    if (count1 >= count2) {
      ans += m / 2 - count1;
      s = s.substr(m / 2 + 1, m / 2);
      s = "#" + s;
    } else {
      ans += m / 2 - count2;
      s = s.substr(1, m / 2);
      s = "#" + s;
    }
    n /= 2;
    ch++;
  }
  cout << ans + 1;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}
