

import java.util.*;
import java.lang.*;

public class AGoodString
{
    static String s = "";

    public static void main (String[] args)
    {
        Scanner in=new Scanner(System.in);
        int t=in.nextInt();
        while(t--!=0)
        {
            int n=in.nextInt();
            s=in.next();
            int q = f(0,n,'a');
            System.out.println(q);
        }
    }

    public static int f(int l,int r,char c)
    {
        if(r-l==1)
        {
            if(s.charAt(l)==c)
                return 0;
            else
                return 1;
        }

        int p1=0;
        int p=0;

        for(int i=l;i<r;i++)
        {
            if(s.charAt(i)==c && i<(l+r)/2)
                p++;
            else if(s.charAt(i)==c && i>=(l+r)/2)
                p1++;
        }

        return Math.min(f(l,(l+r)/2,(char)((int)c+1))+(r-l)/2-p1,f((l+r)/2,r,(char)((int)c+1))+(r-l)/2-p);
    }

}
