import java.io.*;
import java.math.*;
import java.util.*;

public class Solve {
    FastScanner in;
    PrintWriter out;

    char[] c;

    private int diff(int currLetter, int ii, int n) {

        // out.println(ii + " " + n);

        if (n == 1) {
            // out.println((c[ii] == currLetter));
            return ((c[ii] == currLetter) ? 0 : 1);
        }

        int matchPre = 0;
        for (int i = ii; i < ii+(n/2); i++) {
            if (c[i] == currLetter) {
                matchPre++;
            }
        }
        int matchPost = 0;
        for (int i = ii+(n/2); i < ii+n; i++) {
            if (c[i] == currLetter) {
                matchPost++;
            }
        }

        // out.println("pre " + matchPre + " post " + matchPost);


        int a = (n/2) - matchPost + diff(currLetter+1, ii, n/2);
        int b = (n/2) - matchPre + diff(currLetter+1, ii+(n/2), n/2);

        if (a < b) {
            return a;
        } else {
            return b;
        }

        // if (matchPre == 0 && matchPost == 0) {
        //     int a = diff(currLetter+1, ii, n/2);
        //     int b = diff(currLetter+1, ii+(n/2), n/2);
        //     // out.println("ab" + a + " " + b);
        //     if (a < b) {
        //         // out.println("last" + ((n/2) - matchPost + a));
        //         return (n/2) - matchPost + a;
        //     } else {
        //         // out.println("last" + ((n/2) - matchPre + b));
        //         return (n/2) - matchPre + b;
        //     }
        // } else if (matchPre < matchPost) {
        //     // out.println("pre " + ((n/2) - matchPost));
        //     return (n/2) - matchPost + diff(currLetter+1, ii, n/2);
        // } else {
        //     // out.println("post " + ((n/2) - matchPre));
        //     return (n/2) - matchPre + diff(currLetter+1, ii+(n/2), n/2);
        // }
    }

    void solve() {
        int T = in.nextInt();
        while (0 < T--) {
            int n = in.nextInt();
            c = in.next().toCharArray();
            out.println(diff('a', 0, n));
        }
    }

    void run() {
        try {
            in = new FastScanner(new File("Solve.in"));
            out = new PrintWriter(new File("Solve.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new Solve().runIO();
    }
}
