import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class AGoodString {
    public static void main(String[] args) throws Exception {
        //BufferedReader br = new BufferedReader(new FileReader(new File("input.txt")));
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        handleMultipleTestCases(br);
    }

    private static void handleMultipleTestCases(BufferedReader br) throws Exception {
        int T = readInt(br);
        for (int tc = 0; tc < T; tc++) {
            handleTestCase(br);
        }
    }

    private static void handleTestCase(BufferedReader br) throws Exception {
	br.readLine();
	String text = br.readLine();
	System.out.println(changeNeeded(text,0,text.length()-1,'a'));
    }

    private static int readInt(BufferedReader br) throws Exception {
        return Integer.parseInt(br.readLine());
    }

    private static int[] readArrInt(BufferedReader br) throws Exception {
        String[] line = br.readLine().split(" ");
        int[] arr = new int[line.length];
        for (int i = 0; i < line.length; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }
        return arr;
    }

    private static List<Integer> readList(BufferedReader br) throws Exception {
        String[] line = br.readLine().split(" ");
        List<Integer> arr = new ArrayList<>();
        for (int i = 0; i < line.length; i++) {
            arr.add(Integer.parseInt(line[i]));
        }
        return arr;
    }

    private static void print(int[][] mat) {
        System.out.println("----------------------------------------");
        for (int i = 0; i < mat.length; i++) {
            System.out.print("{");
            for (int j = 0; j < mat[0].length; j++) {
                System.out.print(mat[i][j] + " ");
            }
            System.out.println("}");
        }
        System.out.println("----------------------------------------");
    }

    private static void print(int[] mat) {
        System.out.print("{");
        for (int i = 0; i < mat.length; i++) {
            System.out.print(mat[i] + " ");
        }
        System.out.println("}");
    }

    private static int changeNeeded(String text, int start, int end, char init) {
	if(start==end) {
		return init==text.charAt(start)?0:1;
	}else {
		char nextChar = (char)(init+1);
		int mid = (start+end)/2;
		// CASE 1
		int changesOne =0;
	       	for (int i=start;i<=mid;i++) {
			if(init!=text.charAt(i)){
				changesOne++;
			}
		}
		changesOne = changeNeeded(text,mid+1,end,nextChar)+changesOne;
		// CASE 2
		int changesTwo =0;
                for (int i=mid+1;i<=end;i++) {
                        if(init!=text.charAt(i)){
                                changesTwo++;
                        }
                }
                changesTwo = changeNeeded(text,start,mid,nextChar)+changesTwo;
		return Math.min(changesOne,changesTwo);
	}
    }
}

