import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {
            solve(scanner);
        }
    }

    private static void solve(Scanner scanner) {

        int n = scanner.nextInt();
        scanner.nextLine();
        String s = scanner.nextLine();

        int res = goodString(s, 'a');

        System.out.println(res);
    }

    private static int goodString(String s, char a) {
        int length = s.length();
        if (length == 1) {
            if (s.charAt(0) == a) return 0;
            return 1;
        }
        int[] arr = new int[2];
        for (int i = 0; i < length; i++) {
            if (s.charAt(i) == a)
                arr[i * 2 / length]++;
        }
        return Math.min(
                goodString(s.substring(length / 2, length), (char) (a + 1)) + length / 2 - arr[0]
                , goodString(s.substring(0, length / 2), (char) (a + 1)) + length / 2 - arr[1]);
    }
}
