import java.util.Scanner;

public class D {

    public static int minMoves(String str, char c) {
        int move = 0;
        int charInFirstHalf = 0;
        int charInSecondHalf = 0;

        if (str.length() == 1) {
            if (str.charAt(0) == c)
                return 0;
            else
                return 1;
        }

        for (int i = 0; i < str.length() / 2; i++) {
            if (str.charAt(i) == c)
                charInFirstHalf++;
        }
        for (int i = str.length() / 2; i < str.length(); i++) {
            if (str.charAt(i) == c)
                charInSecondHalf++;
        }
        int move1 = minMoves(str.substring(0, str.length() / 2), (char) (c + 1))
                + ((str.length() / 2) - charInSecondHalf);
        int move2 = minMoves(str.substring(str.length() / 2, str.length()), (char) (c + 1))
                + ((str.length() / 2) - charInFirstHalf);

        move = Math.min(move1, move2);
        return move;
    }

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        for (int i = 0; i < t; i++) {
            int n = s.nextInt();
            s.nextLine();
            String str = s.nextLine();
            System.out.println(minMoves(str, 'a'));
        }
        s.close();

    }
}