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

public class codeforces656_D {
    private static void solve(FastIOAdapter ioAdapter) {
        var n = ioAdapter.nextInt();
        char[] s = ioAdapter.next().toCharArray();

        ioAdapter.out.println(calc(s, 'a'));
    }

    private static int calc(char[] s, char ch) {
        if (s.length == 1) {
            return s[0] == ch ? 0 : 1;
        } else {
            int half = s.length / 2;
            char[] half1 = Arrays.copyOfRange(s, 0, half);
            char[] half2 = Arrays.copyOfRange(s, half, s.length);
            int res1 = calc(half1, (char) (ch + 1));
            int count2 = 0;
            for (int i = 0; i < half2.length; i++) {
                if (half2[i] == ch) {
                    count2++;
                }
            }
            res1 += half - count2;

            int res2 = calc(half2, (char) (ch + 1));
            int count1 = 0;
            for (int i = 0; i < half1.length; i++) {
                if (half1[i] == ch) {
                    count1++;
                }
            }
            res2 += half - count1;

            return Math.min(res1, res2);
        }
    }

    public static void main(String[] args) throws Exception {
        try (FastIOAdapter ioAdapter = new FastIOAdapter()) {
            int count = 1;
            count = ioAdapter.nextInt();
            while (count-- > 0) {
                solve(ioAdapter);
            }
        }
    }

    static void shuffleSort(int[] arr) {
        int n = arr.length;
        Random rnd = new Random();
        for (int i = 0; i < n; ++i) {
            int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n - i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
        Arrays.sort(arr);
    }

    static class FastIOAdapter implements AutoCloseable {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        public PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter((System.out))));
        StringTokenizer st = new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

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

        @Override
        public void close() throws Exception {
            out.flush();
            out.close();
            br.close();
        }
    }
}