#include <bits/stdc++.h>
long int ans(char c, std::string str) {
  long int n = str.length();
  if (n == 1) {
    if (str[0] == c) {
      return 1;
    } else {
      return 0;
    }
  }
  std::string first_part = "", second_part = "";
  long int first = 0, second = 0;
  for (int i = 0; i < n; i++) {
    if (i < n / 2) {
      if (str[i] == c) {
        first++;
      }
      first_part += str[i];
    } else {
      if (str[i] == c) {
        second++;
      }
      second_part += str[i];
    }
  }
  return std::max(first + ans(char(c + 1), second_part),
                  second + ans(char(c + 1), first_part));
}
int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    int length;
    std::string str;
    std::cin >> length >> str;
    std::cout << length - ans('a', str) << std::endl;
  }
}
