import java.util.*;
import java.io.*;
import java.text.*;
public class comp
{
	static class FastReader 
	{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	} 

	public static int count(String s, int i, int j, char c)
	{
		int count=0;
		for(; i<=j; i++)
			if(s.charAt(i)==c)
				count++;
		return count;
	}

	public static int goodString(String s, int i, int j, char c)
	{
		if(i==j)
		{
			if(s.charAt(i)==c)
				return 0;
			return 1;
		}
		int mid=(i+j)/2;
		int count1=(j-i)/2+1-count(s,i,mid,c);
		int count2=(j-i)/2+1-count(s,mid+1,j,c);

		count1+=goodString(s,mid+1,j,(char)(c+1));
		count2+=goodString(s,i,mid,(char)(c+1));

		return Math.min(count1,count2);

	}
	
	public static void main(String[] args) throws Exception {
		FastReader sc=new FastReader();
		PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
		
		int t=sc.nextInt();
		int hh=0;
		
		while(hh++<t)
		{
			int n=sc.nextInt();
			String s=sc.next();
			int i;
			int count=goodString(s,0,n-1,'a');
			out.println(count);
		}
		

		out.flush();
	}
}
