
import java.util.Collections;



import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Arrays;

public class CodeChef {
	
	public static int solve(String sr,int al)
	{char ch=(char)al;
	int count1=0,count2=0,count=0;
		if(sr.length()==1)
		{
			if(sr.charAt(0)==ch)
				return 0;
			else return 1;
		}
		else
		{
			for(int i=0;i<sr.length()/2;i++)
			{
				if(sr.charAt(i)==ch)
					count1++;
			}
			for(int i=sr.length()/2;i<sr.length();i++)
			{
				if(sr.charAt(i)==ch)
					count2++;
			}
			if(count1>=count2)
			{
				count=count+sr.length()/2-count1+solve(sr.substring(sr.length()/2, sr.length()),al+1);
				
			}
			if(count1<count2)
			{
				count=count+sr.length()/2-count2+solve(sr.substring(0, sr.length()/2),al+1);
				
			}
		}
	return count;
	}
    public static void main(String args[] ) throws Exception {
 

        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
            int t=Integer.parseInt(br.readLine());
            		while(t-->0)
            		{int n=Integer.parseInt(br.readLine());
            		String sr=br.readLine();
            		
            		System.out.println(solve(sr,97));
            		
            		
	
	




	
}


    } 
}	
	
	
		


