import java.util.*;
public class Main{
    public static int solve(String s,int low,int high,char ch){
        if(low == high){
            return (s.charAt(low) == ch)?0:1;
        }
        int mid = (low+high)/2;
        int ch1 = ch + 1;
        int x1 = solve(s , mid + 1 , high , (char)ch1 ) + cost(s , low , mid , ch );
        if(x1 == 0)
            return x1;
        int x2 = cost(s , mid + 1 , high , ch ) +solve(s , low , mid , (char)ch1 );
        return Math.min(x1,x2);
    }
    public static int cost(String s,int low,int high,char ch){
        int count = 0;
        for(int i = low ; i <= high ; i++){
            if(s.charAt(i) != ch){
                count++;
            }
        }
        return count;
    }
    public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-- > 0){
            int n = sc.nextInt();
            String s = sc.next();
            System.out.println(solve(s,0,n-1,'a'));
        }
    }
}