import java.util.*;


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

public class first{
	
	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;
    
    public static boolean valid(long x,long y,int n,int m)
    {
    	return x>=0 && y>=0 && x<n && y<m;
    }
    public static int p[]=new int[1000000];
    public static int r[]=new int[1000000];
    
   public static long mod=1000000007;
   
  
 public static int rec(String s, int start, int end, char ch )
 {  int n=s.length();
	 if(start==end-1)
	 {
		 if(s.charAt(start)==ch)
			 return 0;
		 else return 1;
		 
	 }
	 String spart1=s.substring(0,n/2);
	 int count1=0;
	 for(int i=0;i<spart1.length();i++)
	 {
		 if(spart1.charAt(i)!=ch)
		 {
			 count1++;
		 }
	 }
	 int ans1=rec(s.substring(n/2),0,n/2,(char)((int)ch+1));
	 
	 String spart2=s.substring(n/2);
	 int count2=0;
	 for(int i=0;i<spart2.length();i++)
	 {
		 if(spart2.charAt(i)!=ch)
		 {
			 count2++;
		 }
	 }
	 int ans2=rec(s.substring(0,n/2),0,n/2,(char)((int)ch+1));
	 
	 return Math.min(ans2+count2, ans1+count1);
 }
   
    public void go() throws IOException
    {   
    	String test =  in.readLine();
    	if(test==null || test.trim().length()==0 )
    		return ;
    	
    	 tok = new StringTokenizer(test);
    
         int tt = Integer.parseInt(tok.nextToken());
    	
    	    
		  for (int q = 0; q < tt; q++) {
		  ntok();
		int n=ipar();
		ntok();
		String s=spar();
		
		int ans=rec(s,0,n,'a');
		 System.out.println(ans);
		  } 
 
        out.flush();
        in.close();
       
    
}
    public void ntok() throws IOException
    {  String test =  in.readLine();
	if(test==null || test.trim().length()==0 )
		return ;
        tok = new StringTokenizer(test);
    }
 
    public int ipar()
    {   String test=tok.nextToken();
      if(test==null || test.trim().length()==0) 
    	  return 0;
      
        return Integer.parseInt(test);
    }
 
    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }
 
    public long lpar()
    { String test=tok.nextToken();
      if(test==null || test.trim().length()==0) 
    	  return 0;
        return Long.parseLong(test);
    }
 
    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }
 
    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }
 
    public String spar()
    { String test=tok.nextToken();
      if(test==null || test.trim().length()==0) 
    	  return "";
        return test;
    }
 
    public static void main(String[] args) throws java.lang.Exception
    {
        new first().go();
    }
    
    static class pair {
    	long f;long s;
    	public pair(long a,long b)
    	{
    		f=a;s=b;
    	}
    }

}