import java.util.Scanner;
public class agoodstrings {
	public static final char xxx = 'a';
	public static void main(String[] args) {
		// TODO Auto-generated method stub
				Scanner sc = new Scanner(System.in);
				int t = Integer.parseInt(sc.nextLine());
				while(t!=0)
				{
					int n = Integer.parseInt(sc.nextLine());
					String s = sc.nextLine();
					int len = n;
					if(n == 1) {
						if(s.charAt(0) == xxx) {
							System.out.println("0");
						}else {
							System.out.println("1");
						}
					}else {
						int sds = calc(s.substring(0,(len/2)),s.substring((len/2),len),xxx);
						System.out.println(sds);
					}
					
					t--;
				}
				
				sc.close();
	}
	public static int calc(String a, String b , char xxx) {
		char xx = xxx;
		char jj = (char)(xxx + '!' - ' ');
		if(a.length() == 1 || b.length() == 1) {
			int val1 = 0,val2 = 0;
			if(a.charAt(0) == xx)
				val1 += 0;
			else
				val1 += 1;
			if(b.charAt(0) == jj)
				val1 += 0;
			else
				val1 += 1;
			if(b.charAt(0) == xx)
				val2 += 0;
			else
				val2 +=1;
			if(a.charAt(0) == jj)
				val2 += 0;
			else
				val2 += 1;
			return Math.min(val1,val2);
		}
		int len1 = a.length();
		int len2 = b.length();
		return Math.min(len1-count(a,xx)+calc(b.substring(0,(len2/2)),b.substring(len2/2,len2),jj) , len2 - count(b,xx)+calc(a.substring(0,(len1/2)),a.substring(len1/2,len1),jj));
	}
	public static int count(String a, char x) {
		int value = 0;
		for(int i = 0 ; i < a.length() ; i++)
			if(a.charAt(i) == x)value++;
		return value;
	}
}
