import java.util.*;
import java.io.*;
public class Codeforces {
	
	public static void main(String[]args) throws IOException
	{
		    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		    int tc=Integer.parseInt(br.readLine());
		    for(int t=0;t<tc;t++) {
		    	
		    	int faltu=Integer.parseInt(br.readLine());
		    	String temp=br.readLine();
		    	
		    	HashMap<String,Integer>map=new HashMap<>();
		    	int x=Integer.MAX_VALUE;
		    		char send=(char)(0+'a');
		    		x=Math.min(x, Find(temp,map,send));
		    	
		    	System.out.println(x);
		    } 
	}

		  private static int Find(String temp,HashMap<String,Integer>map,char send) {
			  
			  if(temp.length()==1)
			  {
				  if(temp.charAt(0)==send)
				  {
					  return 0;
				  }
				  return 1;
			  }
			   int ans=0;
			   int changes=0;
			   for(int i=0;i<temp.length()/2;i++)
			   {
				   if(temp.charAt(i)!=send)
				   {
					   changes++;
				   }
			   }
			   
			   int p1=changes+Find(temp.substring(temp.length()/2),map,(char)(send+1));
			   
			   changes=0;
			   
			   for(int i=temp.length()/2;i<temp.length();i++)
			   {
				   if(temp.charAt(i)!=send)
				   {
					   changes++;
				   }
			   }

			   int p2=changes+Find(temp.substring(0,temp.length()/2),map,(char)(send+1));
			   
			  return Math.min(p1, p2);
			  
		    }
		   
	}