import java.io.PrintWriter;
import java.util.Scanner;

public class aGoodString extends PrintWriter {
    Scanner scanner = new Scanner(System.in);

    aGoodString() {
        super(System.out);
    }

    
    private int makeGoodString(String string, char letter) {
        if (string.length() == 1) {
            if (string.charAt(0) == letter)
                return 0;
            else
                return 1;
        }

        int firstHalfMatches = 0;
        int secondHalfMatches = 0;

        int length = string.length();

        for (int i = 0; i < length; i++) {
            if (i < length / 2) {
                if (string.charAt(i) == letter)
                    firstHalfMatches++;
            } else {
                if (string.charAt(i) == letter)
                    secondHalfMatches++;
            }
        }
        
        letter++;

        // make (c+1)-good string
        int minMovesFirstHalf = makeGoodString(string.substring(0, length / 2), letter);
        int minMovesSecondHalf = makeGoodString(string.substring(length / 2, length), letter);

        int adjustedFirstHalf = (length / 2) - firstHalfMatches + minMovesFirstHalf;
        int adjustedSecondHalf = (length / 2) - secondHalfMatches + minMovesSecondHalf;

        return Math.min(adjustedFirstHalf, adjustedSecondHalf);
    }

    private void solution () {
        int queries = scanner.nextInt();

        for (int i = 0; i < queries; i++) {
            int length = scanner.nextInt();
            String string = scanner.next();
            println(makeGoodString(string, 'a'));
        }
    }


    public static void main(String[] args) {
        aGoodString question = new aGoodString();
        question.solution();
        question.flush();
    }
}
