
import java.io.*;
import java.util.*;
 
public class D 
{	
	static long count=0;
	public static void main(String[] args) throws IOException
	{	
		FastReader f=new FastReader();
		StringBuffer sb=new StringBuffer();
		
		int test=f.nextInt();
		while(test-->0)
		{	
			count=0;
			int n=f.nextInt();
			String s=f.next();
			
			calc(s,'a');
			sb.append(count+"\n");
		}
		System.out.println(sb);
	}
	
	static void calc(String s,char ch)
	{
		if(s.length()==1)
		{
			if(s.charAt(0)!=ch)
				count++;
			return;
		}
		
		int c1=0,c2=0;
		int n=s.length();
		String s1=s.substring(0,n/2);
		String s2=s.substring(n/2,n);
		
		for(int i=0;i<n/2;i++)
		{
			if(s1.charAt(i)!=ch)
				c1++;
			
			if(s2.charAt(i)!=ch)
				c2++;
		}
		if(c2<c1)
		{
			count+=c2;
			calc(s1,(char)(ch+1));
		}
		else
		{	
			count+=c1;
			calc(s2,(char)(ch+1));
		}
	}
	
	static 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; 
	    } 
	} 
}
 