import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Q417July {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t!=0){
            t--;
            int n = sc.nextInt();
            String s = sc.next();
            List<StringBuilder> strings = fillStrings(n,'a');
            System.out.println(findMin(s,strings));
        }
    }

    private static int findMin(String s, List<StringBuilder> strings){
        int min = Integer.MAX_VALUE;
        for (StringBuilder string : strings) {
            int count = findCount(s, string.toString());
            if (count < min) {
                min = count;
            }
        }
        return min;
    }

    private static int findCount(String s, String match){
        int count=0;
        for(int i =0;i<s.length();i++){
            if(s.charAt(i)!= match.charAt(i)){
                count++;
            }
        }
        return count;
    }


    private static List<StringBuilder> fillStrings(int length, char initial){
        if(length == 1){
            return new ArrayList<>(
                    Collections.singletonList(new StringBuilder(Character.toString(initial))));
        }

        List<StringBuilder> s1 = fillStrings(length/2, (char)(initial+1));
        List<StringBuilder> s2 = new ArrayList<>(s1);
        appendBeforeAfter(s1,s2,initial, length/2);
        s1.addAll(s2);
        return s1;
    }

    private static  void appendBeforeAfter(List<StringBuilder> appendBeforeList, List<StringBuilder> appendAfterString, char appendWith, int length){
        String repeatedInitials =  repeatedInitials(appendWith,length);
        for (StringBuilder s : appendBeforeList) {
            s.reverse().append(repeatedInitials).reverse();
        }

        for (StringBuilder s : appendAfterString) {
            s.append(repeatedInitials);
        }
    }

    private static String repeatedInitials(char initials, int length){
        StringBuilder s = new StringBuilder();
        for(int i =0;i<length;i++)
        {
            s.append(initials);
        }
        return s.toString();
    }
}


