import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
public class Pd{
	public static void main(String[] args) throws IOException{
		FastReader sc = new FastReader();
		BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out),"ASCII"),512);
		int t = sc.nextInt();
		while(t-- > 0){
			int n = sc.nextInt();
			char[] ch = sc.nextLine().toCharArray();
			if(n == 1){
				if(ch[0] != 'a') out.write(1 + "");
				else out.write(0 + "");
			}else{
				out.write(totalCount(ch,1,n,'a') + "");
			}
			out.write('\n');
		}
		out.flush();
	}
	public static int totalCount(char[] ch,int l,int r,char c){
		int count = 0;
		count += Math.min(countFirst(ch,l-1,r-1,c),countSecond(ch,l-1,r-1,c));
		return count;
	}
	public static int countFirst(char[] ch,int l,int r,char c){
		if(l==r){
			if(ch[l] != c) return 1;
			else return 0;
		}
		int count = 0;
		int mid = l+(r-l)/2;
		for(int i=l;i<=mid;i++){
			if(ch[i] != c) count++;
		}
		count += Math.min(countFirst(ch,mid+1,r,(char)(c+1)),countSecond(ch,mid+1,r,(char)(c+1)));
		return count;
	}
	public static int countSecond(char[] ch,int l,int r,char c){
		if(l==r){
			if(ch[l] != c) return 1;
			else return 0;
		}
		int count = 0;
		int mid = l+(r-l)/2;
		for(int i=mid+1;i<=r;i++){
			if(ch[i] != c) count++;
		}
		count += Math.min(countFirst(ch,l,mid,(char)(c+1)),countSecond(ch,l,mid,(char)(c+1)));
		return count;
	}
}
class FastReader{
	BufferedReader br;
	StringTokenizer st;
	public FastReader(){
		br = new BufferedReader(new InputStreamReader(System.in));
	}
	String next(){
		while(st == null || !st.hasMoreElements()){
			try{ 
				st = new StringTokenizer(br.readLine()); 
			} 
			catch (IOException  e){ 
				e.printStackTrace(); 
			} 
		} 
		return st.nextToken();
	}
	int nextInt(){ 
        return Integer.parseInt(next()); 
	}
    long nextLong(){ 
        return Long.parseLong(next()); 
    }
    double nextDouble(){ 
        return Double.parseDouble(next()); 
    }
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
		catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    }
}