#include <bits/stdc++.h>
using namespace std;
string arr = "abcdefghijklmnopqrstuvwxyz";
int fir_or_sec(string c, int x, int a) {
  int ans = 0;
  if (a == 0) {
    for (int i = 0; i < c.length() / 2; i++) {
      if (c[i] == arr[x]) ans++;
    }
  } else {
    for (int i = c.length() / 2; i < c.length(); i++) {
      if (c[i] == arr[x]) ans++;
    }
  }
  return ans;
}
int checker(string &c, int n, int i) {
  if (c.length() == 1) {
    if (c[0] == arr[i]) {
      return 0;
    } else {
      return 1;
    }
  }
  int first, second;
  first = fir_or_sec(c, i, 0);
  second = fir_or_sec(c, i, 1);
  string first_half = "", second_half = "";
  for (int i = 0; i < n; i++) {
    if (i < n / 2)
      first_half = first_half + c[i];
    else
      second_half = second_half + c[i];
  }
  int fi = 9999999;
  int se = 9999999;
  if (n / 2 - first > n / 2 - second) {
    fi = (checker(first_half, n / 2, i + 1) + n / 2 - second);
  } else if (n / 2 - second > n / 2 - first)
    se = (checker(second_half, n / 2, i + 1) + n / 2 - first);
  else {
    fi = (checker(first_half, n / 2, i + 1) + n / 2 - second);
    se = (checker(second_half, n / 2, i + 1) + n / 2 - first);
  }
  return min(fi, se);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    string c;
    cin >> n >> c;
    int length = c.length();
    int ans = checker(c, n, 0);
    cout << ans << endl;
  }
}
