import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.time.LocalTime;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;



public class D {

	static int n;
	static char [] ch;
	
    public static void main(String[] args) {
    	FastScanner scan = new FastScanner();
    	int t = scan.nextInt();
    	for(int tt=0; tt<t; tt++) {
    		n = scan.nextInt();
    		ch = scan.next().toCharArray();
    		int ans = go(0, n-1, 'a', 0);
    		System.out.println(ans);
    	}
   }
    
    
    static int go(int start, int end, char c, int count) {
    	char next = c;
    	next++;
    	if(start == end) {
    		if(ch[start] == c) return count;
    		else return count+1;
    	}
    	if(start + 1 == end) {
    		if((ch[start] == next && ch[end] == c) || (ch[start] == c && ch[end] == next)) return count;	
    		else if(ch[start] == next || ch[start] == c || ch[end] == next || ch[end] == c) return count+1;
    		else return count+2;
    	}
    	int mid = (start + end)/2;
    	//split first half
    	int amount = count(start, mid, c);
    	int option1 = go(mid + 1, end, next, count + amount);
    	//split second half
    	amount = count(mid + 1, end, c);
    	int option2 = go(start, mid, next, count + amount);
    	
    	return Math.min(option1, option2);
    }
    
    static int count(int start, int end, char c) {
    	int count = 0;
    	for(int i=start; i<=end; i++) {
    		if(ch[i] != c) count++;
    	}
    	return count;
    }
    
   
	public static void sort(int [] a) {
    	ArrayList<Integer> b = new ArrayList<>();
    	for(int i: a) b.add(i);
    	Collections.sort(b);
    	for(int i=0; i<a.length; i++) a[i]= b.get(i);
    }
    
    static class FastScanner{
    	
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");
    	String next() {
    		while(!st.hasMoreTokens())
    			try {
    				st = new StringTokenizer(br.readLine());
    			} catch (IOException e){
    				e.printStackTrace();
    			}
    		return st.nextToken();
    	}
    	
    	int nextInt() {
    		return Integer.parseInt(next());
    	}
    	
    	int [] readArray(int n) {
    		int [] a = new int[n];
    		for(int i=0; i<n ; i++) a[i] = nextInt();
    		return a;
    	}
    	
    	long nextLong() {
    		return Long.parseLong(next());
    	}
    	
    	
    }
    
   
}

