import java.util.*;

public class Main{
	public static int good(char[] a, int start, int end, char c){
		if(start==end){
			if(a[start]==c)
				return 0;
			else
				return 1;
		}

		HashMap<Character, Integer> map1 = new HashMap<>();
		HashMap<Character, Integer> map2 = new HashMap<>();
		map1.put(c, 0);
		map2.put(c, 0);
		char temp = c;

		int mid = (start+end)/2;

		for(int i=start; i<=mid; i++){
			if(map1.containsKey(a[i]))
				map1.put(a[i], map1.get(a[i])+1);
			else
				map1.put(a[i], 1);
		}

		for(int i=mid+1; i<=end; i++){
			if(map2.containsKey(a[i]))
				map2.put(a[i], map2.get(a[i])+1);
			else
				map2.put(a[i], 1);
		}

		while(map1.get(c)==map2.get(c) &&  c<='z'){
			c++;
			if(!map1.containsKey(c))
				map1.put(c, 0);

			if(!map2.containsKey(c))
				map2.put(c, 0);
		}	

		if(c>'z'){
			c=temp;
			int changes = mid-start-map1.get(c)+1;
			c++;
			return changes+good(a, mid+1, end, c);
		}

		// System.out.println(c);

		if(c==temp){
			if(map1.get(c)>map2.get(c)){
				int changes = mid-start-map1.get(temp)+1;
				// System.out.println(start+" "+mid+" "+changes);
				temp++;
				return changes+good(a, mid+1, end, temp);
			}else{
				int changes = end-mid-map2.get(temp);
				// System.out.println(mid+" "+end+" "+changes);
				temp++;
				return changes+good(a, start, mid, temp);
			}
		}
		else{
			if(map1.get(c)<map2.get(c)){
				int changes = mid-start-map1.get(temp)+1;
				// System.out.println(start+" "+mid+" "+changes);
				temp++;
				return changes+good(a, mid+1, end, temp);
			}else{
				int changes = end-mid-map2.get(temp);
				// System.out.println(mid+" "+end+" "+changes);
				temp++;
				return changes+good(a, start, mid, temp);
			}
		}
	}
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int t = scan.nextInt();

		while(t>0){
			int n = scan.nextInt();
			String s = scan.next();

			char[] a = s.toCharArray();

			System.out.println(good(a, 0, n-1, 'a'));


			t--;
		}
	}
}