import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in= new Scanner(System.in);
		int t=in.nextInt();
		while(t-->0){
			int n=in.nextInt();
			String s=in.next();
			
			int m=1+(int)(Math.log(n)/Math.log(2));
			int count=0;
			int t1=0;
			int t2=0;
			int k=0;
			int j=0;
			while(n>=1){
				for(int i=j;i<j+n/2;i++){
					if(s.charAt(i)==(char)(97+k))
					t1++;
				}		
				for(int i=n/2+j;i<n+j;i++){
					if(s.charAt(i)==(char)(97+k))
					t2++;
				}
				
				if(t1>=t2){
				count+=(n/2-t1);
				j=n/2;
				}
				else{
				count+=(n/2-t2);
				j=0;
				}
				
				n=n/2;
				k++;
				t1=0;
				t2=0;
			}
			
			if(count>=1)	
			System.out.println(count-1);
			else
			System.out.println(0);
		}
	}
}