import java.util.*;

public class Code {

	

	//static int n;
	
		public static void main(String[] args)
	{
		
		Scanner sc=new Scanner(System.in);
	    int t=sc.nextInt();
	   
	    while(t-->0)
	    {
	  int  	  n=sc.nextInt();
	    	 
	    	String s=sc.next();
	    	
    	 int ans=rec(s,'a');
	    System.out.println(ans);
	    }
	
	
	}

		private static int rec(String s, char c) {
			// TODO Auto-generated method stub
		int	n=s.length()/2;
			if(s.length()==1)
			{
				if(s.charAt(0)==c)
				{
					return 0;
				}
				return 1;
			}
			//opt1 starting
			int count=0;
			for(int i=0;i<n;i++)
			{
				if(s.charAt(i)==c)
				{
					count++;
				}
			}
			int opt1=rec(s.substring(n),(char)(c+1))+n-count;
			count=0;
			for(int i=n;i<s.length();i++)
			{
				if(s.charAt(i)==c)
				{
					count++;
				}
			}
			int opt2=rec(s.substring(0,n),(char)(c+1))+n-count;
			
			return Math.min(opt1, opt2);
		}	
}
