#include <bits/stdc++.h>
using namespace std;
int chk(string a, char b) {
  int c = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] != b) {
      c++;
    }
  }
  return c;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    string s;
    cin >> s;
    int size = s.size();
    int mid = size / 2;
    if (size == 1) {
      mid = 1;
    }
    int sum = 0;
    int k = 1, pwr = 0;
    while (1) {
      if (k == size) {
        break;
      }
      k = 2 * k;
      pwr++;
    }
    char X[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                  'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                  's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
    for (int i = 0; i <= pwr; i++) {
      if (size != 1) {
        int m = mid - 1;
        string a1, a2;
        a1 = s.substr(0, mid);
        a2 = s.substr(m + 1, size - 1);
        int b1, b2;
        b1 = chk(a1, X[i]);
        b2 = chk(a2, X[i]);
        if (b1 > b2) {
          sum = sum + b2;
          s.erase(m + 1, size - 1);
        }
        if (b1 < b2) {
          sum = sum + b1;
          s.erase(0, mid);
        }
        if (b1 == b2) {
          for (int j = i + 1; j <= pwr; j++) {
            int c1, c2;
            c1 = chk(a1, X[j]);
            c2 = chk(a2, X[j]);
            if (c1 < c2) {
              sum = sum + b2;
              s.erase(m + 1, size - 1);
              break;
            }
            if (c1 > c2) {
              sum = sum + b1;
              s.erase(0, mid);
              break;
            }
            if (j == pwr) {
              sum = sum + b1;
              s.erase(0, mid);
            }
          }
        }
        size = s.size();
        mid = size / 2;
        continue;
      }
      if (size == 1) {
        if (s[0] != X[i]) {
          sum = sum + 1;
          break;
        }
        if (s[0] == X[i]) {
          break;
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}
