//package codeforces._656;

import java.io.*;
import java.util.StringTokenizer;

public class _656_D {

    public static void main (String[] args) throws Exception {

        String s = "6\n" +
                "8\n" +
                "bbdcaaaa\n" +
                "8\n" +
                "asdfghjk\n" +
                "8\n" +
                "ceaaaabb\n" +
                "8\n" +
                "bbaaddcc\n" +
                "1\n" +
                "z\n" +
                "2\n" +
                "ac";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int T = nin();
        next_test:
        for (int t=1; t<=T; ++t) {
            rl(); int n=nin();
            rl(); char S[]=nca();

            int C=rec(S, 'a', 0, n);
            bw.write(Integer.toString(C));
            bw.newLine();
        }
        bw.flush();
    }

    static int rec(char[] S, char c, int from, int to) {
        if (to-from==1) return S[from]==c ? 0 : 1;

        int middle=from+(to-from+1)/2;

        int c1 = 0;
        for (int i=from; i<middle; ++i) {
            if (S[i]!=c) ++c1;
        }
        c1 += rec(S, (char)(c+1), middle, to);

        int c2 = 0;
        for (int i=middle; i<to; ++i) {
            if (S[i]!=c) ++c2;
        }
        c2 += rec(S, (char)(c+1), from, middle);
        return Math.min(c1, c2);
    }

    static BufferedReader br; static BufferedWriter bw; static StringTokenizer st;
    static void rl() throws Exception{ st = new StringTokenizer(br.readLine()); }
    static long nlo(){ return Long.parseLong(st.nextToken()); }
    static int nin(){ return Integer.parseInt(st.nextToken()); }
    /*private static void te(){}*/
    static double ndo(){ return Double.parseDouble(st.nextToken()); }
    static char[] nca(){ return st.nextToken().toCharArray(); }
}
