import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Tree {
    static int runCase(String a, char x) {
        if (a.length() == 1) {
            if (a.charAt(0) != x) {
                return 1;
            } else {
                return 0;
            }

        }
        int mid = a.length() / 2;
        int cntl = runCase(a.substring(0, mid), (char) (x + 1));
        for (int i = mid; i < a.length(); i++) {
            if (a.charAt(i) != x) cntl++;
        }
        int cntr = runCase(a.substring(mid, a.length()), (char) (x + 1));
        for (int i = 0; i < mid; i++) {
            if (a.charAt(i) != x) cntr++;
        }
        return Math.min(cntl, cntr);
    }
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();

        while (t!=0) {

            int n = sc.nextInt();
            String s = new String();
            sc.nextLine();
            s=sc.nextLine();
            Tree X = new Tree();
            int m=X.runCase(s,'a');

            System.out.println(m);

            t--;
        }
    }
}


