import java.io.*;
import java.util.*;
public class er92C {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
		int test = Integer.parseInt(inp.readLine());
		while(test-->0)
		{
			int n = Integer.parseInt(inp.readLine());
			String str = inp.readLine();
			System.out.println(goodString(str, 'a', n));
		}
	}
	public static int goodString(String s, char ch, int l)
	{
		if(l<=0) return 0;
		if(l==1)
		{
			if(s.charAt(0)==ch) return 0;
			else return 1;
		}
		int count1=0, count2=0;
		for(int i=0;i<l/2;i++)
		{
			if(s.charAt(i)!=ch) count1++;
		}
		int a = goodString(s.substring(l/2), (char)(ch+1), l/2);
		for(int i=l/2;i<l;i++)
		{
			if(s.charAt(i)!=ch) count2++;
		}
		//System.out.println("kks2");
		int b = goodString(s.substring(0, l/2), (char)(ch+1), l/2);	
		return  Math.min(count1+a, count2+b);
	}
}