	// _________________________RATHOD_____________________________________________________________
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;  
public class Main 
{
    static ArrayList<ArrayList<Integer>> graph;
    static int visited[];
    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; 
        } 
    } 
    static String s;
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
        int t=sc.nextInt();
        while(t>0)
        {
            t--;
            int n=sc.nextInt();
            s=sc.next();
            char ch='a';
            if(n==1)
            {
                if(s.charAt(0)=='a')
                System.out.println(0);
                else
                System.out.println(1);
            }
            if(n!=1)
            System.out.println(countc(1,n,ch,n));
            
           
        }
        
    }
    public static int countc(int st,int e,char ch,int size)
    {
                int   mid=((e-st+1)/2)+st-1;
                int l=countf(ch,st,mid);
                int r=countf(ch,(mid+1),e);
                int rl=size/2-l;
                int rr=size/2-r;
                if(size==2)
                {
                   if(s.charAt(st-1)==ch)
                   {
                     if(s.charAt(e-1)==(ch+1))
                     {
                       return 0;
                     }  
                     else
                     return 1;
                   }
                   else
                   {
                      if(s.charAt(st-1)==ch+1)
                     {
                     if(s.charAt(e-1)==(ch))
                     {
                       return 0;
                     }  
                     else
                     return 1;
                     }
                     else
                     {
                       if(s.charAt(e-1)==(ch))
                     {
                       return 1;
                     }  
                     else
                     return 2;   
                     }
                       
                   }
                }
                else
                {
                    
                    int lll=(countc(st,mid,((char) (ch+1)),size/2)+rr);
                    int rrr=(countc(mid+1,e,((char) (ch+1)),size/2)+rl);
                   // System.out.println(lll+" "+rrr);
                    return((int) Math.min(lll,rrr));
                }
    }
    public static int countf(char ch,int st,int e)
    {
        int i;
        int count=0;
        for(i=st-1;i<=e-1;i++)
        {
            if(s.charAt(i)==ch)
            count++;
        }
        return count;
    }
} 
 