
import java.util.*;
public class prac2 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int t=0;
		if(sc.hasNextInt())
			t = sc.nextInt();
		int rep = 0;
		for(int h=0;h<t;h++)
		{
			int n = sc.nextInt();
			if(sc.hasNextLine())
				sc.nextLine();
			String str = sc.nextLine();
			
			System.out.println(check(str,'a'));
		}
		
	}
	public static int check(String str,char c)
	{
		if(str.length()==0) return 0;
		if(str.length()==1 && str.charAt(0)==c) return 0;
		if(str.length()==1 && str.charAt(0)!=c) return 1;
		int left=0,right=0,n = str.length(),score=0;
		for(int i=0;i<n/2;i++)
		{
			if(str.charAt(i)!=c)
				left++;
		}
		for(int i=n/2;i<n;i++)
		{
			if(str.charAt(i)!=c)
				right++;
		}
		if(left<right)
		{
			score+=left;
			str = str.substring(n/2);
		}
		else if(right<left)
		{
			score+=right;
			str = str.substring(0, n/2);
		}
		else
		{
			int score1 = check(str.substring(0, n/2),(char) (c+1));
			int score2 = check(str.substring(n/2),(char) (c+1));
			if(score1<score2)
			{
				score+=left;
				str = str.substring(0,n/2);
			}
			else
			{
				score+=right;
				str = str.substring(n/2);
			}
			
		}
		score+=check(str,(char)(c+1));
		return score;
	}

}
