import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int sol(char[] A, char a) {
        if (A.length == 1) {
            //System.out.printf("%s %c%n", Arrays.toString(A), a);
            return A[0] != a ? 1 : 0;
        }

        int mid = A.length/2;
        int left = 0;
        int leftn = 0;
        for (int i = 0 ; i < mid ; i++) {
            if (A[i] != a) {
                left++;
                if (A[i] == (char)(a + 1)) {
                    leftn++;
                }
            }
        }
        int right = 0;
        int rightn = 0;
        for (int i = mid ; i < A.length ; i++) {
            if (A[i] != a) {
                right++;
                if (A[i] == (char)(a + 1)) {
                    rightn++;
                }
            }
        }

        if (left == right && left == mid) {
            //System.out.printf("%d %d %d %d%n", left, right, leftn, rightn);
            if (leftn == Math.max(1, mid/2)) {
                return left + sol(Arrays.copyOfRange(A, 0, mid), (char)(a + 1));
            } else if (rightn == Math.max(1, mid/2)) {
                return right + sol(Arrays.copyOfRange(A, mid, A.length), (char)(a + 1));
            }
        }
        if (left <= right) {
            return left + sol(Arrays.copyOfRange(A, mid, A.length), (char)(a + 1));
        } else {
            return right + sol(Arrays.copyOfRange(A, 0, mid), (char)(a + 1));
        }
    }
    static void app(Scanner scanner) {
        int T = scanner.nextInt();
        for (int iT = 0 ; iT < T ; iT++) {
            scanner.nextInt();
            char[] A = scanner.next().toCharArray();
            System.out.println(sol(A, 'a'));
        }
    }
    public static void main(String[] args) {
        app(new Scanner(System.in));
    }
}
