import java.io.*;
import java.util.*;
import java.math.*;

public class A_Good_String
{
	InputReader in;PrintWriter pw;
	char str[];

	long pow(long base,long power)
	{
		if(power==0) return 1L;
		long temp = 1L;
		if(power%2==1)
		{
			temp = base;
		}
		base = (base*base);
		return (temp*pow(base,power/2L));
	}

	long getAns(int l,int r ,char ch)
	{
		//pn(l+" "+r);
		int mid = (int)Math.floor((l+r)/(double)2);
		if(r-l+1 == 1)
		{
			if(str[l] == ch) return 0;
			return 1;
		}

		long c1 =0,c2=0;
		for(int i=l;i<=mid;i++)
		{
			if(str[i] != ch)
				c1++;
		}

		for(int i=mid+1;i<=r;i++)
		{
			if(str[i] != ch)
				c2++;
		}

		return Math.min(c1+getAns(mid+1,r,(char)(ch+1)),c2+getAns(l,mid,(char)(ch+1)));
	}
	void solve(int test) throws Exception
	{
		int n = ni();
		str = nln().toCharArray();
		pn(getAns(0,n-1,'a'));
	}
	void run() throws Exception 
	{
		in = new InputReader();
		pw = new PrintWriter(System.out);
		int test = ni();
		while(test--!=0){solve(test);}
		pw.close();
	}
	public static void main(String[] args) throws Exception
	{
		new A_Good_String().run();
	}

	void p(Object o){pw.print(o);}
	void pn(Object o){pw.println(o);}
	void pn(){pw.println();}
	void spn(Object o){System.out.println(o);};
	String nln() throws Exception {return in.nextLine();}
	int ni() throws Exception {return Integer.parseInt(in.next());}
	double nd() throws Exception {return Double.parseDouble(in.next());}
	long nl() throws Exception {return Long.parseLong(in.next());}
	class InputReader
	{
		BufferedReader br;
		StringTokenizer st;

		public InputReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public InputReader(String s) throws IOException
		{
			br = new BufferedReader(new FileReader(s));
		}

		String next() throws Exception
		{
			if(st==null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					throw new Exception(e.toString());
				}
			}
			return st.nextToken();
		}

		String nextLine() throws Exception
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch(IOException e)
			{
				throw new Exception(e.toString());
			}
			return str;
		}
	}
}