import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        while(t-- != 0){
            int n = s.nextInt();
            String str = s.next();
            System.out.println(solve(str,0,n - 1,'a'));
        }
    }
    public static int solve(String str,int start,int end,char c){
        if(start > end){
            return 0;
        }
        if(start == end){
            if(c == str.charAt(start)){
                return 0;
            }
            return 1;
        }
        int mid = (start + end + 1)/2,c1 = 0,c2 = 0;
        for(int i = start; i < mid; i++){
            if(str.charAt(i) != c){
                c1++;
            }
        }
        for(int i = mid; i <= end; i++){
            if(str.charAt(i) != c){
                c2++;
            }
        }
        c = (char)(c + 1);
        int a = c1 + solve(str,mid,end,c);
        int b = c2 + solve(str,start,mid - 1,c);
        return Math.min(a,b);
    }
}