import java.util.Scanner;
	
public class Main {
	static boolean isSame(String s,char c) {
		boolean flag=true;
		for(char i:s.toCharArray()) {
			if(i!=c) flag=false;
		}
		return flag;
	}
	static boolean isGood(String s,char c) {
		if(s.length()==1) return s.charAt(0)==c;
		String left=s.substring(0, s.length()/2);
		String right=s.substring(s.length()/2);
		return isSame(left,c)&&isGood(right,(char)(c+1))||isSame(right,c)&&isGood(left,(char)(c+1));
	}
	static int fromSame(String s,char c) {
		int n=0;
		for(char i:s.toCharArray()) {
			if(i!=c) n++;
		}
		return n;
	}
	static int fromGood(String s,char c) {
		if(s.length()==1) return s.charAt(0)==c?0:1;
		String left=s.substring(0, s.length()/2);
		String right=s.substring(s.length()/2);
		return Math.min(fromSame(left,c)+fromGood(right,(char)(c+1)), fromSame(right,c)+fromGood(left,(char)(c+1)));
	}
	
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int number=0;
		if(scan.hasNextInt()) number=scan.nextInt();
		String []str=new String[number];
		int []len=new int[number];
		for(int i=0;i<number;i++) {
			if(scan.hasNextInt()) len[i]=scan.nextInt();
			if(scan.hasNext()) str[i]=scan.next();
		}
		for(int i=0;i<number;i++) {
			System.out.println(fromGood(str[i],'a'));
		}
		scan.close();
	}

}
