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;
		}
		if(n==2) {
			if(s.charAt(i)==d && s.charAt(i+1) == int2char(char2int(d)+1)) {
				return 0;
			}
			if(s.charAt(i+1)==d && s.charAt(i) == int2char(char2int(d)+1)) {
				return 0;
			}
			if(s.charAt(i)==d || s.charAt(i+1) == d) {
				return 1;
			}
			if(s.charAt(i) == int2char(char2int(d)+1) || s.charAt(i+1) == int2char(char2int(d)+1)) {
				return 1;
			}
			return 2;
		}
		int intd = char2int(d);
		int lower = 0;
		if(i!=0) {
			lower = c[i-1][intd];
		}
		int mid = (i+n-1)/2;
		int first = n/2 - (c[mid][intd] - lower);
		int last = n/2 - (c[i+n-1][intd] - c[mid][intd]);
		
		int p =  Math.min(first+makeGood(s,int2char(intd+1),mid+1,n/2), last+makeGood(s,int2char(intd+1),i,n/2));
		//System.out.println(s.substring(i,i+n)+" "+p);
		return p;
	}
}
