import java.io.*;
import java.util.*;

public class Main2 {
	
	static int[][] c;
	private static int char2int(char a) {
		return (int) (a - 'a');
	}
	private static char int2char(int x) {
		if(x>25) {
			x = x%25;
		}
		return (char)('a'+x);
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int tk = in.nextInt();
		
		for(int pt=0;pt<tk;pt++) {
			int n = in.nextInt();
			String s= in.next();
			c = new int[n][26];
			for(int i=0;i<n;i++) {
				if(i!=0) {
					for(int j=0;j<26;j++) {
						c[i][j] = c[i-1][j];
					}
				}
				c[i][char2int(s.charAt(i))]++;
			}
			int k = makeGood(s,'a',0,n);
			System.out.println(k);
		}
	}
	private static int makeGood(String s, char d, int i, int n) {
		if(n==0) {
			return 0;
		}
		if(n==1) {
			if(s.charAt(i) == d) {
				return 0;
			}
			return 1;
		}
		int first = 0;
		int last = 0;
		for(int j=0;j<n/2;j++) {
			if(s.charAt(i+j)!=d) {
				first++;
			}
		}
		for(int j=n/2;j<n;j++) {
			if(s.charAt(i+j)!=d) {
				last++;
			}
		}
		
		return Math.min(first+makeGood(s,(char)(d+1),i+n/2,n/2), last+makeGood(s,(char)(d+1),i,n/2));
	}
}
