#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
int width(int x) { return sizeof(int) * 8 - __builtin_clz(x); }
int n;
string s;
pair<int, int> calc(int l, int r, int lv) {
  if (r == l + 1) return {s[l] - 'a' != lv, s[l] - 'a' != lv - 1};
  int m = (r + l) / 2;
  pair<int, int> la = calc(l, m, lv + 1);
  pair<int, int> ra = calc(m, r, lv + 1);
  int acc = 0;
  for (int i = l; i < (r); i++)
    if (s[i] - 'a' != lv - 1) acc++;
  return {min(la.first + ra.second, la.second + ra.first), acc};
}
void solve() {
  cin >> n >> s;
  cout << calc(0, n, 0).first << "\n";
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  for (int qq = 0; qq < (tt); qq++) solve();
}
