import java.util.*;
public class c {
	static int moves(char[] arr , int s , int e , char c)
	{
		
		if (s==e)
		{
			if (arr[s]==c) return 0;
			else return 1;
		}
		else if (s>e) return 0;
		int mid = (s+e)/2;
		int cc1 = 0;
		int cc2 = 0;
		int len = e-s+1;
		for (int i=s;i<=mid;i++)
		{
			if (arr[i]==c) cc1++;
		}
		for (int i=mid+1;i<=e;i++)
		{
			if (arr[i]==c) cc2++;
		}
		int r1 = moves(arr , mid+1 , e , (char)(c+1));
		int r2 = moves(arr , s , mid , (char)(c+1));
		return Math.min((len/2 - cc1) + r1, (len/2 - cc2)+r2);
	}
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		while (t-->0)
		{
			int n = s.nextInt();
			char[] str = s.next().toCharArray();
			int res = moves(str , 0 , n-1,'a');
			System.out.println(res);
		}
	}
}
