import java.util.*;
import java.io.*;
import java.lang.Math;


public class Solution{

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();
		int t = fs.nextInt();

		while(t-->0){

			int n = fs.nextInt();
			char[] arr = fs.next().toCharArray();

			System.out.println(minMoves(arr, 0, n-1, 'a'));
		}
	}

	static int minMoves(char[] arr, int l, int r, char c){
		if(l==r){
			if(arr[l]==c)
				return 0;
			else
				return 1;
		}

		int mid = (l+r)/2;

		int c1 = count(arr, l, mid, c) + minMoves(arr, mid+1, r, (char)(c+1));
		int c2 = minMoves(arr, l, mid, (char)(c+1)) + count(arr, mid+1, r, c);

		return Math.min(c1, c2);
	}


	static int count(char[] arr, int l, int r, char c){
		int n = r-l+1;
		int s = 0;
		for(int i=l;i<=r;i++){
			if(arr[i]==c) s++;
		}
		return n-s;
	}





	


	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}
	}

}