import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class AGood {
    static int getCompleteCount(String s,int start,int end,char b){
        HashMap <Character,Integer>count=new HashMap<>();
        for(int i=start;i<end;i++){
            char c=s.charAt(i);
            if(count.containsKey(c)){
                count.replace(c, count.get(c)+1);
            }
            else{
                count.put(c,1);
            }
        }
        int sum=0;
        int max=Integer.MIN_VALUE;
        for(char c:count.keySet()){
            int value=count.get(c);
            sum+=value;
        }
        if(!count.containsKey(b))
            return sum;
        return sum-count.get(b);
    }
    static int getCount(String s,int start,int end,char c){
        if(end-start==1){
            if(c==s.charAt(start))
                return 0;
            else
                return 1;
        }
        int mid=start+(end-start)/2;
        int n1=getCount(s, start,mid,(char)(c+1))+getCompleteCount(s, mid, end,c);
        int n2=getCount(s, mid,end,(char)(c+1))+getCompleteCount(s, start, mid,(char)(c));
        return Math.min(n1,n2);
    }
    public static void main(String[]args)throws IOException{
        BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(r.readLine());
        while(t-->0){
            r.readLine();
            String s=r.readLine().trim();
            System.out.println(getCount(s, 0, s.length(), 'a'));
        }
    }
    
}