import java.util.*;

public class CF_656_D {

	
	public static int rec(char ch,String str,int st,int en)
	{
		if(st == en)
		{
			if(ch == str.charAt(st))
				return 0;
			else
				return 1;
		}
		int mid = (en+st)/2;
//		System.out.print(mid + " ");
		int c1=0,c2 = 0;
		for(int i = st;i<=en;++i)
		{
			if(str.charAt(i) == ch && i<=mid)
			{
				c1++;
			}
			else if(str.charAt(i) == ch && i>mid)
			{
				c2++;
			}
		}
		return Math.min((((en-st+1)/2) - c2)+ rec((char)((int)ch+1),str,st,mid),(((en-st+1)/2) - c1)+ rec((char)((int)ch+1),str,mid+1,en));
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int T = s.nextInt();
		while(T>0)
		{
			int n = s.nextInt();
			String str = s.next();
			System.out.println(rec('a',str,0,n-1));
			T--;
		}
	}

}
