#include <bits/stdc++.h>
using namespace std;
int getHao(string a, int start, int end, string mark) {
  int left_hao = 0;
  int right_hao = 0;
  string same = mark;
  if (end - start > 1) {
    mark[0]++;
    left_hao = getHao(a, start, (end + start - 1) / 2, mark);
    right_hao = getHao(a, (end + start + 1) / 2, end, mark);
  }
  if (end - start == 1) {
    int times = 0;
    string same1 = same;
    if (a[start] == same1[0]) {
      same1[0]++;
      if (a[end] != same1[0]) {
        times++;
      }
    } else {
      if (a[end] == same1[0]) {
        same1[0]++;
        if (a[start] != same1[0]) {
          times++;
        }
      } else {
        times++;
        times++;
      }
    }
    return times;
  }
  if (end - start == 0) {
    if (a[0] == mark[0]) {
      return 0;
    } else {
      return 1;
    }
  }
  int left_same = 0;
  int right_same = 0;
  for (int i = start; i <= end; i++) {
    if (a[i] == same[0] && i <= (end + start - 1) / 2) left_same++;
    if (a[i] == same[0] && i >= (end + start + 1) / 2) right_same++;
  }
  if ((end - start) / 2 + left_hao - right_same >
      (end - start) / 2 - left_same + right_hao) {
    return (end - start + 1) / 2 - left_same + right_hao;
  } else {
    return (end - start + 1) / 2 + left_hao - right_same;
  }
}
int main() {
  string startMark("a");
  int c;
  string a;
  int b;
  cin >> c;
  int *store = new int[c];
  for (int i = 0; i < c; i++) {
    cin >> b;
    cin >> a;
    store[i] = getHao(a, 0, b - 1, startMark);
  }
  for (int i = 0; i < c; i++) {
    cout << store[i] << endl;
  }
}
