import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    cf656D.solve();
    }
}

class cf656D {

    private static char[] str ;
    private static int n;



    public static void solve(){
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        int t = sc.nextInt();
        for (int T = 0; T < t; T++) {
            n = sc.nextInt();
            str = sc.next().toCharArray();
            System.out.println(getMove(0,n, 'a'));
        }
    }

    private static int getMove(int L, int R, char c) {
        if(L + 1 == R)
            return str[L] == c ? 0 : 1;

        int mid = L + (R - L)/2;
        int leftCnt = 0, rightCnt = 0;
        for (int i = L; i < mid; i++) {
            if(str[i] != c)
                leftCnt++;
        }
        for (int i = mid; i < R; i++) {
            if(str[i] != c)
                rightCnt++;
        }
        return Math.min(
                leftCnt + getMove(mid, R, (char) (c + 1)),
                rightCnt + getMove(L, mid, (char) (c + 1))
        );
    }
}

