import java.util.Scanner;

public class aGoodString {

        public static int change(int l, int r, String s, char x ){

            int ans=0;
            for(int i=l;i<=r;i++){
                if(s.charAt(i)!=x)
                    ans=ans+1;
            }
            return ans;

        }

        public static int checkGood(int l, int r, String s, char x){

            if(l==r)
                return (s.charAt(l)=='x')? 0:1;
            
            int mid=(r+l)/2;
            
            int z=change(l, mid, s, x);
            int y=change(mid+1, r, s, x);
            
            int c1= checkGood(mid+1, r, s, (char)((int)x+1));
            int c2= checkGood(l, mid, s, (char)((int)x+1));

            return Math.min(c1+z,c2+y);
        }


        public static void main(String[] args) {

            Scanner s = new Scanner(System.in);

            int t = s.nextInt();

            while (t-- > 0) {

                int n=s.nextInt();
                // char[] st=new char[n];

                // for(int i=0;i<n;i++)
                //     st[i]=s.next().charAt(0);

                // String str=st.toString();
                String str=s.next();
                System.out.println(checkGood(0, n-1, str, 'a'));
            }

        }

}
