/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
    static int func(String str,int s,int e,char c)throws java.lang.Exception
    {
        
        if((e-s+1)==1)
        {
           if( str.charAt(s)!=c)
            return 1;
            return 0;
        }
        
        int mid=(s+e)/2;
        
        int c1=0,c2=0;
        for(int i=s;i<=mid;i++)
        {
            if(str.charAt(i)!=c)
            c1++;
        }
        for(int i=mid+1;i<=e;i++)
        {
            if(str.charAt(i)!=c)
            c2++;
        }
        
        
        char d=(char)(c+1);
         c1=(c1+func(str,mid+1,e,d));
         c2=(c2+func(str,s,mid,d));
         
         return Math.min(c1,c2);
    }
   public static void main (String[] args) throws java.lang.Exception
	{
	    
// -----------------------------Fast IO using BufferedReader-----------------------------------------------------------------	    

// 		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
//          StringTokenizer st = new StringTokenizer(br.readLine());
//          PrintWriter out = new PrintWriter(System.out); 
//          int T = Integer.parseInt(st.nextToken()); 
// ----------------------------------------------------------------------------------------------------------	    
    Scanner sc=new Scanner(System.in); 
    int T=sc.nextInt();
		while(T-- >0)
		{
		    
          int N=sc.nextInt();sc.nextLine();
          
		  String s=sc.nextLine();
		  
		  if(s.length()==1)
		  {
		      if(s.charAt(0)=='a')
		      System.out.println(0);
		      else
		       System.out.println(1);
		  }
		  else
		  System.out.println(func(s,0,N-1,'a'));

		}
// 		out.close();   
	}
}
