//package CodeForces;

import java.util.Scanner;

public class AGoodString {
	
	static int calc(String str,int i,int j,int ch)
	{
		int count=0;
		for(int k=i;k<=j;k++)
		{
			if((str.charAt(k)-'a')!=ch)
			{
				count++;
			}
		}
		return count;
	}
	
	static int solve(String str,int i,int j,int ch)
	{
		if(i>j)
		{
			return 0;
		}
		if(i==j)
		{
			if(str.charAt(i)-'a'==ch)
			{
				return 0;
			}
			else
			{
				return 1;
			}
		}
		
		int mid=(i+j)/2;
		return Math.min(solve(str,mid+1,j,ch+1)+calc(str,i,mid,ch),solve(str,i,mid,ch+1)+calc(str,mid+1,j,ch));
	}

	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(solve(str,0,str.length()-1,0));
			t--;
		}

	}

}
