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 s = sc.next();
            int ans = getMin(s, 0, n - 1, checker);
            System.out.println(ans);
        }
    }

    private static int getMin(String s, int l, int r, char checker) {
        if (l == r) {
            if (s.charAt(l) == checker)
                return 0;
            else
                return 1;
        }
        int mid = (l + r) / 2;
        return Math.min(getCost(s, mid + 1, r, checker) + getMin(s, l, mid, (char) ((int) checker + 1)),
                getCost(s, l, mid, checker) + getMin(s, mid + 1, r, (char) ((int) checker + 1)));
    }

    private static int getCost(String s, int l, int r, char c) {
        int cnt = 0;
        for (int i = l; i <= r; i++)
            if (s.charAt(i) != c)
                cnt++;
        return cnt;
    }
}
