

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class experiments
{	
	public static void main(String args[]) throws IOException
	{
		FastScanner fs = new FastScanner();
		int T = fs.nextInt();
		while(T-- > 0)
		{
			int n = fs.nextInt();
			String str = fs.next();
			int move = goodString(str,'a');
			System.out.println(move);
		}
	}

	private static int goodString(String str,char c) {
		
		int n = str.length();
		if (n==0 || n == 1 && str.charAt(0) == c) return 0;
		if(n==0 || n == 1 && !(str.charAt(0) == c))	return 1;
		
		int first=0,second=0,moves=0;
		for(int i=0; i<n; i++)
			if(i<n/2 && !(str.charAt(i) == c))
				first++;
			else if(!(str.charAt(i) == c))
				second++;
		
			return Math.min(first + goodString(str.substring(n/2,n),(char)(c+1)), second + goodString(str.substring(0,n/2),(char)(c+1)));
	}

}
class FastScanner
{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer str = new StringTokenizer("");
	
	String next() throws IOException
	{
		while(!str.hasMoreTokens())
			str = new StringTokenizer(br.readLine());
		
		return str.nextToken();
	}
	
	int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}
	
	float nextfloat() throws IOException
	{
		return Float.parseFloat(next());
	}
	
	double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}
	long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}
	int[] arrayIn(int n) throws IOException
	{
		int arr[] = new int[n];
		for(int i=0; i<n; i++)
		{
			arr[i] = nextInt();
		}
		return arr;
	}
}



	