import java.io.*;                                                                                                                                              
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        // solve
        while(n-->0) {
            int k = in.nextInt();
            String s = in.next();
            System.out.println(good(s,'a'));
        }
    }

    private static int good(String s, int c) {
        if(s.length()==1) return notChar(s,c);
        else return Math.min(notChar(left(s),c)+good(right(s),c+1),
                        notChar(right(s),c)+good(left(s),c+1));
    }

    private static int notChar(String s, int c) {
        int diff=0;
        for(int i=0;i<s.length();i++) {
            if(s.charAt(i) != c) diff++;
        }
        return diff;
    }

    private static String left(String s) {
        return s.substring(0,s.length()/2);
    }

    private static String right(String s) {
        return s.substring(s.length()/2,s.length());
    }
}
