import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Sample{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int testcase = sc.nextInt();
        while (testcase-->0) {
            int n = sc.nextInt();
            sc.nextLine();
            String str = sc.nextLine();
            char[] chars = str.toCharArray();
            System.out.println(makeGood(chars ,'a',0 ,n));;


        }



    }
    static int makeGood(char[] chars , char ch,int start , int end){
        if(end-start==1){
            if(chars[start]==ch)return 0;
            return 1;
        }
        int first = 0;
        int second = 0;
        int mid = (start+end)/2;
        for(int i=start;i<mid;i++)if(chars[i]!=ch)first++;
        for(int i = mid ; i<end;i++)if(chars[i]!=ch)second++;
             int c1= first+makeGood(chars , (char)(ch+1),mid,end);
             int c2 =second+makeGood(chars ,  (char)(ch+1) , start , mid);
            return Math.min(c1 ,c2);
    }
}