import java.util.Scanner;

public class D{
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int t = input.nextInt();
		// input.nextLine();
		while(t-- != 0){
			int n = input.nextInt();
			input.nextLine();
			String s = input.nextLine();
			if(s.length() == 1){
				if(s.charAt(0) == 'a'){
					System.out.println(0);
				}
				else
					System.out.println(1);
				continue;
			}
			System.out.println(solve(s, 'a', 0));

		}
	}

	public static int solve(String s, char ch, int ans){
		int half = s.length()/2;
		int frst = 0;
		int scnd = 0;
		if(s.length() == 1){
			if(s.charAt(0) == ch){
				return ans;
			}
			return ++ans;
		}
		for(int i = 0; i < half; i++){
			if(s.charAt(i) == ch){
				frst++;
			}
			if(s.charAt(half*2-1-i) == ch){
				scnd++;
			}
		}
		// System.out.println(frst + " " + ch + " " + ans);
		// System.out.println(scnd + " " + ch + " " + ans);
		// System.out.println("---------------------");
		if(frst > scnd){
			ans += half - frst;
			return solve(s.substring(half), ++ch, ans);
		}
		if(scnd > frst){
			ans += half - scnd;
			return solve(s.substring(0, half), ++ch, ans);
		}
		else{
			ans += half - scnd;
			return Math.min(solve(s.substring(half), ++ch, ans), solve(s.substring(0, half), ++ch, ans));
		}

	}
}