import java.io.*;
import java.util.*;

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();
            String s = sc.next();
            
            System.out.println(isGood(s, 'a'));
        }
    }
    
    private static int isGood(String s, char c) {
        int n = s.length();
        
        if(n <= 0) return 0;
        
        // System.out.println(c);
        
        if(n == 1) {
            if(s.charAt(0) == c) return 0;
            return 1;
        }
        
        // System.out.println(s);
        
        int cCountLeft = 0;
        for(int i=0;i<n/2;i++) {
            if(s.charAt(i) == c) cCountLeft++;
        }
        
        int cCountRight = 0;
        for(int i=(n/2);i<n;i++) {
            if(s.charAt(i) == c) cCountRight++;
        }
        // System.out.println(cCountLeft + " " + cCountRight);
        if(cCountLeft == n/2) {
            return isGood(s.substring((n/2), n), (char)((int)c+1));
        }
        
        if(cCountRight == n/2) {
            return isGood(s.substring(0,(n/2)), (char)((int)c+1));
        }
        
        return Math.min(((n/2) - cCountLeft + isGood(s.substring((n/2), n), (char)((int)c+1))) ,
                        ((n/2) - cCountRight + isGood(s.substring(0,(n/2)), (char)((int)c+1))));
        // return 0;
    }
}