import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;

public class D1381 {
	public static void main(String[] args) throws IOException{
		Scanner scanner = new Scanner(System.in);
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
		int cases = scanner.nextInt();
		for(int i = 0; i < cases; i++) {
			int n = scanner.nextInt();
			String given = scanner.next();
			int result = 0;
			int limit1 = 0;
			int limit2 = n;
			char min = 'a';
			for(int k = 1; k < n; k *= 2) {
				//char[][] sep = new char[2][n / 2];
				int temp2 = (limit1 + limit2) / 2;
				int temp1 = (limit1 + limit2) / 2;
				int compare1 = countDif(given, limit1, temp2, min);
				int compare2 = countDif(given, temp1, limit2, min);
				if(compare1 > compare2)
					limit2 = temp2;
				else
					limit1 = temp1;
				result += Math.min(compare1, compare2);
				min++;
			}
			result += countDif(given, limit1, limit2, min);
			log.write("" + result + "\n");
		}
		log.flush();
	}

	private static int countDif(String given, int i, int temp, char compare) {
		int count = 0;
		for(i = i; i < temp; i++) {
			if(given.charAt(i) != compare) {
				count++;
			}
		}
		return count;
	}
}