
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-- != 0){
            int n = sc.nextInt();
            sc.nextLine();
            String ss = sc.nextLine();
            System.out.println(dfs(ss,0,n-1,'a'));
        }
    }

    private static int dfs(String ss,int l, int r, char c) {
        if(l == r) {
            if(ss.charAt(l) != c) return 1;
            else return 0;
        }
        int mid = (l + r)/2;
        int numl = 0;
        int numr = 0;
        for (int i=l;i<=mid;i++){
            if(ss.charAt(i) != c) numl++;
        }
        for (int i=mid+1;i<=r;i++){
            if(ss.charAt(i) != c) numr++;
        }
        return Math.min(numl+dfs(ss,mid+1,r,(char) (c+1)),numr+dfs(ss,l,mid,(char) (c+1)));
    }
}

		  		 		 			  		 		 	  					 	