import java.util.*;
public class Main

{
    public static int getAns(String str,char ch)
    {
        if(str.length()==1)
         {
             if(str.charAt(0)==ch)return 0;
             else return 1;
         }
        int firstHalf=0,secondHalf=0;
        for(int i=1;i<=str.length();i++)
        {
            if(str.charAt(i-1)!=ch)
            {
                if(i>(str.length()/2))secondHalf++;
                else firstHalf++;
            }
        }
        ch=(char)(ch+1);
        return Math.min(firstHalf+getAns(str.substring(str.length()/2,str.length()),ch),secondHalf+getAns(str.substring(0,str.length()/2),ch));
    }
	public static void main(String[] args) {
		Scanner kb=new Scanner(System.in);
		int t=kb.nextInt();
		while(t-->0)
		{
		    int n=kb.nextInt();
		    String str=kb.next();
		    System.out.println(getAns(str,'a'));
		}
	}
}
