import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;


public class Main
{
	static int n;
	static String s;
	static List<Integer> list;
	static int k;
	public static void main(String[] args) throws NumberFormatException, IOException
	{
		BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw= new BufferedWriter(new OutputStreamWriter(System.out));
		int nm= Integer.parseInt(br.readLine());
		
		for(int ll=0; ll<nm; ll++)
		{
			n= Integer.parseInt(br.readLine());
			s= br.readLine();
			list = new ArrayList<>();
			k= n;
			
			re(97, 0, 0, n/2);
			Collections.sort(list);
			System.out.println(list.get(0));
		}
	} 
	
	public static void re(int ch, int i, int sum, int k)
	{
		if(k==0)
		{
			if(s.charAt(i)!=(char)ch)
				sum++;
			list.add(sum);
		}
		else
		{
			int nn=0;
			for(int j=i; j<i+k; j++)
				if(s.charAt(j)!=(char)ch)
					nn++;
			
			re(ch+1, i+k, sum+nn, k/2);
			
			int nnn=0;
			for(int j=i+k; j<i+k+k; j++)
				if(s.charAt(j)!=(char)ch)
					nnn++;
			re(ch+1, i, sum+nnn, k/2);
		}
	}
}
