
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for (int i = 0; i < n; i++) {
            int num = scan.nextInt();
            String s = scan.next();
            System.out.println(divide(s,0,num-1,'a'));
        }
    }

    public static int divide(String s,int p,int q,char target){
        if(p == q ){
            if(s.charAt(p) != target)
            return 1;
            else
                return 0;
        }
        int mid = (p+q)/2;
        int match1 = 0;
        int match2 = 0;
        for(int i=p;i<mid+1;i++){
            if(s.charAt(i) == target){
                match1+=1;
            }
        }
        for(int i=mid+1;i<q+1;i++){
            if(s.charAt(i) == target){
                match2+=1;
            }
        }
        int pp = 0, qq=0;
        if(match1 > match2){
            pp+=(mid-p+1 - match1);
            int l = (int) target;
            l+=1;
            target = (char)l;
            qq = divide(s,mid+1,q,target);
        }
        else if(match2 > match1){
            pp+=(mid-p+1 - match2);
            int l = (int) target;
            l+=1;
            target = (char)l;
            qq = divide(s,p,mid,target);
        }
        else{
            int l = (int) target;
            l+=1;
            target = (char)l;
            return min(divide(s,p,mid,target)+(mid-p+1)-match1,divide(s,mid+1,q,target)+(mid-p+1)-match1);
        }

        return pp+qq;


    }

    public static int min(int a,int b){
        return a>b?b:a;
    }






}