import java.util.Scanner;
	
	public class Solution {

		public static void main(String[] args) {
			
			Scanner scan = new Scanner(System.in);
			int t = scan.nextInt();
			
			while(t-->0) {
				int n =scan.nextInt();
				String str= scan.next();
				System.out.println(count(str,'a'));
				
			}
			
			scan.close();
		}
		
		public static int count(String s, char c) {
			if(s.length()==1) {
				if(s.charAt(0)==c) return 0;
				else return 1;
			}
			int mid = s.length()/2;
			int lc = count(s.substring(0,mid),(char)(c+1));
			lc+=mid-countChar(s.substring(mid,s.length()), c);
			int rc = count(s.substring(mid,s.length()),(char)(c+1));
			rc+=mid-countChar(s.substring(0,mid), c);
			
			return Math.min(lc, rc);
		}
		
		public static int countChar(String s, char c) {
			int ans=0;
			for(int i=0;i<s.length();i++) {
				if(s.charAt(i)==c) ans++;
			}
			return ans;
		}
		
	}