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 q4
{
	public static void main (String[] args) throws java.lang.Exception
	{
        // your code goes here
        Scanner sc = new Scanner(System.in);
        int t= Integer.parseInt(sc.next());
        while(t-->0)
        {
            int n = Integer.parseInt(sc.next());
            String str= sc.next();
            int ans=help(str,0,n-1,'a');
            System.out.println(ans);
        }
    }
    public static int help(String str , int l,int r,int a)
    {
        if(l==r)
        {
            if(str.charAt(l)==a)
            {
                return 0;
            }
            return 1;
        }
        int mid=(r+l)/2;
        int c1=0,c2=0;
        for(int i =l;i<=mid;i++)
        {
            if(str.charAt(i)!=a)
            {
                c1++;
            }
        }
        for(int i= mid+1;i<=r;i++)
        {
            if(str.charAt(i)!=a)
            {
                c2++;
            }
        }
        return Math.min(c1+help(str,mid+1,r,a+1), c2+help(str,l,mid,a+1));
    }
}