import java.util.*; 
import java.lang.*;
import java.io.*;
public class Main 
{ 
    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 FastReader s = new FastReader();
    public static int answer(int start,int end,String str,char req){
        int cntLeft =0;
        int cntRight = 0;
        int ans = 0;
        int half = (end-start+1)/2;
        char next = (char)(req+1);
        int nextLeft = 0;
        int nextRight = 0;
        if(start==end){
            if(str.charAt(start)==req){
                return 0;
            }
            else{
                return 1;
            }
        }
        for(int i=start;i<(start+half);i++){
            // System.out.println(i);
            if(str.charAt(i)==req){
                cntLeft++;
            }
            if(str.charAt(i)==next)
                nextLeft++;
        }
        for(int i=end;i>(end-half);i--){
            if(str.charAt(i)==req){
                cntRight++;
            }      
            if(str.charAt(i)==next)
                nextRight++;
        }
        if(cntLeft==cntRight){
            if(nextLeft>=nextRight){
                req++;
                ans = Math.max(0,(half-cntRight));
                int temp = answer(start,end-half,str,req);
                // System.out.println((char)(req-1)+" "+ans+" temp "+temp+" "+cntLeft+" "+cntRight);
                ans = ans + temp;
            }
            else{
                req++;
                ans = Math.max(0,(half-cntLeft));
                int temp = answer(start+half,end,str,req);
                // System.out.println((char)(req-1)+" "+ans+" "+temp+" "+cntLeft+" "+cntRight);
                ans = ans + temp;
            }
        }
        else if(cntLeft>cntRight){
            req++;
            ans = Math.max(0,(half-cntLeft));
            int temp = answer(start+half,end,str,req);
            // System.out.println((char)(req-1)+" "+ans+" "+temp+" "+cntLeft+" "+cntRight);
            ans = ans + temp;
        }
        else{
            req++;
            ans = Math.max(0,(half-cntRight));
            int temp = answer(start,end-half,str,req);
            // System.out.println((char)(req-1)+" "+ans+" temp "+temp+" "+cntLeft+" "+cntRight);
            ans = ans + temp;
        }
        return ans;
    }
    public static void solve(){
        int n = s.nextInt();
        String string  = s.nextLine();
        int ans = answer(0,n-1,string,'a');
        System.out.println(ans);
    }
    public static void main(String[] args) 
    {  
        int T=1;
        T = s.nextInt();
        while(T>0){
            // System.out.println("TEST CASE: "+T);
            // System.out.println(string);
            solve();
            T--;
        }
    } 
}
class Pair{
    int first;
    int second;
    Pair(int a,int b){
        this.first = a;
        this.second = b;
    }    
}
