import java.util.*;

public class GoodString {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            String s = sc.next();
            int result = findChar(s, 'a', 0, x - 1);
            System.out.println(result);

        }
        sc.close();
    }

    public static int findChar(String s, char ch, int start, int end) {

        if (start < end) {
            // System.out.println(start + " " + end);

            int cnt = 0;
            int j = start;
            int totalLength = end - start + 1;
            int last = start + totalLength;
            int mid = start + totalLength / 2;
            // System.out.println("Mid: " + mid);
            // System.out.println("last: " + last);

            int lt = 0;
            while (j < mid) {
                if (s.charAt(j) != ch) {
                    lt++;
                }
                j++;
            }
            int rt = 0;
            while (j < last) {
                if (s.charAt(j) != ch) {
                    rt++;
                }
                j++;
            }

            if (lt > rt) {
                cnt += rt;
                // System.out.println(" lt " + rt);
                return cnt += findChar(s, (char) (ch + 1), start, mid - 1);
            } else if (rt > lt) {
                cnt += lt;
                // System.out.println(" rt " + lt);
                return cnt += findChar(s, (char) (ch + 1), mid, end);
            } else {
                cnt += rt;
                int tempA = findChar(s, (char) (ch + 1), start, mid - 1);
                int tempB = findChar(s, (char) (ch + 1), mid, end);
                return cnt += Math.min(tempA, tempB);
            }
        } else if (start == end) {
            if (s.charAt(start) != ch)
                return 1;
            else
                return 0;
        }
        return 0;
    }

}