/* 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 Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	int t=Integer.parseInt(bf.readLine());
	while(t-->0)
	{
	    sum=0;
	    int n=Integer.parseInt(bf.readLine());
	    String s=bf.readLine();
	    check(0,s.length()-1,n,97,s);
	    System.out.println(sum);
	 //   System.out.println("testcase khtm");
	    
	}
	
	}
static int sum=0;
public static void check(int start,int end,int n,int z,String s)
{
    if(n==0)
    return;
    if(n==1)
    {
        if(s.charAt(start)==(char)z)
        {
            return;
        }
        else
        sum=sum+1;
        return;
    }
    if(n==2)
    {
        if(s.charAt(start)==(char)z || s.charAt(end)==(char)z)
        {
            if(s.charAt(start)==(char)z+1 || s.charAt(end)==(char)z+1)
            {
                return;
                
            }
            else
            {
                sum=sum+1;
                return;
            }
            
        }
        else
        {
            if(s.charAt(start)==(char)z+1 || s.charAt(end)==(char)z+1)
            {
                sum=sum+1;
                return;
                
            }
            else
            {
                sum=sum+2;
                return;
            }
            
        }
    }
 //   char c=(char)z;
    int a[]=new int[26];
    int b[]=new int[26];
    for(int i=start;i<=start+((end-start+1)/2)-1;i++)
    {
        int p=s.charAt(i)-97;
        a[p]++;
        
    }
    for(int i=(end-start+1)/2;i<=end;i++)
    {
        int p=s.charAt(i)-97;
        b[p]++;
        
    }
//    System.out.println("a  "+Arrays.toString(a));
//     System.out.println("b  "+Arrays.toString(b));
    for(int i=z-97;i<26;i++)
    {
        if(i==z-97 )
        {
        if(a[i]!=b[i])
        {
            if(a[i]>b[i])
            {
                sum=sum+(n/2-a[i]);
            //    System.out.println("sum1 "+sum);
             //   z++;
           //  System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check((start+(end-start+1)/2),end,n/2,(z+1),s);
                break;
            }
            else
            {
                sum=sum+(n/2-b[i]);
             //   System.out.println("sum2 "+sum);
            //     System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
              //  z++;
                check(start,(start+(end-start+1)/2)-1,n/2,(z+1),s);
                break;
            }
        }
        }
        else
        {
            if(a[i]!=b[i])
          {
            if(a[i]<b[i])
            {
                sum=sum+(n/2-a[z-97]);
             //   z++;
           //  System.out.println("sum3 "+sum);
           //   System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check(start+(end-start+1)/2,end,n/2,(z+1),s);
                break;
            }
            else
            {
                sum=sum+(n/2-b[z-97]);
              //  z++;
           //   System.out.println("sum4 "+sum);
           //    System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check(start,(start+(end-start+1)/2)-1,n/2,(z+1),s);
                
                break;
            }
        }
            
        }
    }
    
    
    
}
}