import java.lang.*;
import java.util.*;
public final class Test
{
    public static String find(String s,int st,int end,char ch)
    {
        if(st==end)
        {
            if(s.charAt(st)==ch)
             return 0+" "+'s';
            else
             return 1+" "+'s';
        }
        int mid=(st+end)/2;
        int c1=0,c2=0;
        int n1=0,n2=0;
        char next=(char)(ch+1);
        for(int i=mid+1;i<=end;i++)
        {
         if(s.charAt(i)==ch)
          c2++;
         if(s.charAt(i)==next)
          n2++;
        }
        for(int i=st;i<=mid;i++)
        {
         if(s.charAt(i)==ch)
          c1++;
         if(s.charAt(i)==next)
          n1++;
        }
         int ans;
         char c;
        if(c1>c2)
        {
            ans=mid+1-c1-st;
            c='s';
        }
        else if(c1==c2)
        {
            if(n1>n2)
            {
                ans=mid+1-c2-st;
                c='e';
            }
            else
            {
                ans=mid+1-c1-st;
                c='s';
            }
        }
        else
        {
           // System.out.println(mid+" "+c2+" "+st);
            ans=mid+1-c2-st;
            c='e';
        }
        return ans+" "+c;
        
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        for(int i=0;i<t;i++)
        {
            int n=sc.nextInt();
            String s=sc.next();
            int st=0,end=n-1;
            char ch='a';
            int count=0;
            while(st<=end)
            {
             String[] ans=find(s,st,end,ch).split(" ");
             //System.out.println(ans[0]+" "+ans[1]);
             count=count+(Integer.parseInt(ans[0]));
             int mid=(st+end)/2;
             if(ans[1].equals("s"))
              st=mid+1;
             else
              end=mid;
             ch=(char)(ch+1);
             //System.out.println(ch);
              
            }
            System.out.println(count);
        }
    }
}