//package prob.daniels;

import java.util.Arrays;
import java.util.Scanner;

public class MakingGoodString {
    private static long count ;
    public static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int test = scanner.nextInt();
        while(test>0) {
            count = 0;
            int n = scanner.nextInt();
            scanner.nextLine();
            String s = scanner.nextLine();
            System.out.println(makingGood(s, 'a'));
            test--;
        }
    }

     public static long makingGood(String s,char a) {
        int start = -1;
        int end = -1;
         if(s.length() == 1) {
//             System.out.println("String "  +s);
//             System.out.println("Count : " + count);
            if(s.indexOf(a)!=0)
                    count++;
          //   System.out.println("Count : " + count);
             return count;
         }
//         System.out.println("String "  +s);
//         System.out.println("Character : "  + a);
        int getIndex = s.indexOf(a);
//         System.out.println("getIndex : " + getIndex);
        if(getIndex >=0 && getIndex < s.length()/2) {
            start = 0;
            end = s.length()/2 ;
        } else if(getIndex>=s.length()/2) {
           start = s.length()/2;
            end = s.length() ;
        } else {
            getIndex = s.indexOf(a + 1);
            if(getIndex>=0 && getIndex<s.length()/2) {
                start = s.length()/2;
                end = s.length() ;
            } else if(getIndex>=s.length()/2 || getIndex == -1) {
                start  = 0;
                end = s.length()/2 ;
            }
        }
         count += nothingDoing(s,start,end,a);
//         System.out.println("Start : " + start);
//         System.out.println("end : "+end);
//         System.out.println("Count : " + count);
//         System.out.println("s.length/2 : "+s.length()/2);
         if(end == s.length()/2)
             end--;
      //   System.out.println(end<s.length()/2);
        if(end<s.length()/2) {
           //System.out.println("1st call");
            makingGood(s.substring(s.length()/2),(char)(a+1));
        } else {
      //      System.out.println("2nd call");
            makingGood(s.substring(0,s.length()/2),(char)(a+1));
        }
        return count;
     }

     public static int nothingDoing(String s,int start,int end,char a) {
        String tempString = s.substring(start,end );
        char[] tempArray = tempString.toCharArray();
         Arrays.sort(tempArray);
         tempString = new String(tempArray);
//         System.out.println("LastIndex : " + tempString.lastIndexOf(a));
//         System.out.println("TempStrings length : " + tempString.length());
         return  tempString.length() - (tempString.lastIndexOf(a) + 1) ;
     }
}
