import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public final class CodeForces {
    static int ans;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        while(t-->0) {
            int n = Integer.parseInt(br.readLine());
            String s = br.readLine();
            ans = Integer.MAX_VALUE;
            if(n > 1) {
                solve(s, 'a', 0);
                System.out.println(ans);
            } else {
                System.out.println(s.charAt(0) == 'a' ? 0 : 1);
            }
        }
        br.close();
    }

    private static void solve(String s, char c, int val) {
        int count1 = 0, count2 = 0;
        if(s.length() == 1) {
            if(s.charAt(0) == c) {
                ans = Math.min(ans, val);
            } else {
                ans = Math.min(ans, val+1);
            }
            return;
        }
        String s1 = s.substring(0, s.length()/2);
        String s2 = s.substring(s.length()/2);
        for(int i=0; i<s1.length(); i++) {
            if(s1.charAt(i) == c)
                count1++;
            if(s2.charAt(i) == c)
                count2++;
        }
        char next = (char) (c + 1);
        solve(s2, next, val + s1.length() - count1);
        solve(s1, next, val + s2.length() - count2);
    }
}