/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class GFG {
   public  static int count(char arr[],int i ,int j,char x){
       int f=0;
       for(int k =i;k<=j;k++){
           if(arr[k]==x){
               f++;
           }
       }
       return f;
   }
   public  static int helper(char arr[], int i , int j , int dp[][][] , char x){
        if(i==j){
            int f=count(arr,i,j,x);
            if(f==0){
                dp[i][j][x-'a']=1;
            }
            else
              dp[i][j][x-'a']=0;
              
            return dp[i][j][x-'a'];
        }
        if(dp[i][j][x-'a']!=-1){
            return dp[i][j][x-'a'];
        }
        int mid=i+(j-i)/2;
        int f1=count(arr,i,mid,x);
        int f2=count(arr,mid+1,j,x);
       
          int opt1=mid+1-f1;
            
            opt1+=helper(arr,mid+1,j,dp,(char)(x+1)); 
            
          int opt2=(j-mid)-f2;
            
            opt2+=helper(arr,i,mid,dp,(char)(x+1));
            
            dp[i][j][x-'a']=Math.min(opt1,opt2);  
        
        return dp[i][j][x-'a'];
    }
	public static void main (String[] args) {
		Scanner s= new Scanner(System.in);
		 int t =s.nextInt();
		 while(t-->0){
		     int n =s.nextInt();
		     String str= s.next();
		     char arr[]= str.toCharArray();
		     int dp[][][]= new int[n][n][26];
		     for(int a[][]:dp){
		         for(int k[]:a){
		             Arrays.fill(k,-1);
		         }
		     }
		     int ans=helper(arr,0,n-1,dp,'a');
		     System.out.println(ans);
		     
		 }
	}
}