import java.util.*;
public class AGoodString {

	public static void main(String[] args) {
		Scanner s= new Scanner(System.in);
		int t =s.nextInt();
		while(t-->0) {
			int n = s.nextInt();
			char[] arr = s.next().toCharArray();
			System.out.println(getans(arr,0,n-1,'a'));
		}
	}
 
	private static int getans(char[] arr, int start , int last , char ch) {
		if(start==last) {
			if(arr[start]==ch) {
				return 0;
			}
			return 1;
		}
		int mid = start+(last-start)/2;
		return Math.min(getcost(arr, start, mid,ch)+ getans(arr,mid+1,last,(char) (ch+1)),
				getcost(arr,mid+1,last,ch)+getans(arr,start,mid,(char) (ch+1)));
	}

	private static int getcost(char[] arr,int start , int last, char ch) {
		int cost =0;
		for(int i=start;i<=last;i++) {
			if(arr[i]!=ch) {
				cost++;
			}
		}
		return cost;
	}

}
