import java.util.Scanner;

public class hello {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            char checker = 'a';
            String half = sc.next();
            int ans = 0;
            while (half.length() > 1) {
                String half1 = "";
                String half2 = "";
                int c = 0, d = 0;
                for (int i = 0; i < half.length() / 2; i++) {
                    half1 += half.charAt(i);
                    if (half.charAt(i) == checker) {
                        c++;
                    }
                }
                for (int i = half.length() / 2; i < half.length(); i++) {
                    half2 += half.charAt(i);
                    if (half.charAt(i) == checker) {
                        d++;
                    }
                }
                ans += Math.min((half.length() / 2) - c, (half.length() / 2) - d);
                if (c == d)
                    half = half2;
                else if (c > d)
                    half = half2;
                else
                    half = half1;
                checker = (char) ((int) checker + 1);
            }
            if (half.charAt(0) != checker)
                System.out.println(ans + 1);
            else System.out.println(ans);
        }
    }
}
