import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Code {
   
    public static void main(String[] args) throws IOException
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        StringBuilder res = new StringBuilder();
        int t = sc.nextInt();
        while (t-- > 0) {
        	int len = sc.nextInt();
        	String s = sc.next();
        	int result = halve(s, 'a');
        	pw.println(result);
        }
        pw.close();
	}
    public static int halve(String str, char c)
    {
    	int count1 = 0;
    	int count2 = 0;
    	if (str.length() == 1)
    	{
    		if (str.charAt(0) == c)
    		{
    			return 0;
    		}
    		else
    		{
    			return 1;
    		}
    	}
    	int half1 = 0;
    	int len = str.length()/2;
    	for (int i = 0; i <  len; i++)
    	{
    		if (str.charAt(i) == c)
    		{
    			half1++;
    		}

    	}
    	int half2 = 0;
    	for (int i = len; i < str.length(); i++)
    	{
    		if (str.charAt(i) == c)
    		{
    			half2++;
    		}
    	}

    	count1 += (len - half1);
    	count1 += halve(str.substring(len), (char)(c +1));
    
    	count2 += (len - half2);
    	count2 += halve(str.substring(0, len), (char)(c +1 ));
    	
    	return Math.min(count1, count2);
    	
    }

	
}

