def solve(s,f,n,ss,c):
        s1=s[f:(f+n)//2]
        s2=s[(f+n)//2:n]
        j1=s1.count(c)
        j2=s2.count(c)
        sss=len(s1)
        #print(j1,j2,c,s[f:(f+n)//2],s[(f+n)//2:n],ss,f,n,sss)
        if j1>j2:
            k=sss-j1
            f=(f+n)//2
            j1=0
            s1=0
        elif j1==j2:
            if s1.count(chr(ord(c)+1))<s2.count(chr(ord(c)+1)):
                k=sss-j1
                f=(f+n)//2
                j1=0
                s1=0
            else:
                k=sss-j2
                n=(f+n)//2
                j2=0
                s2=0
        else:
            k=sss-j2
            n=(f+n)//2
            j2=0
            s2=0
        ss+=k
        #print(j1,j2,c,s[f:(f+n)//2],s[(f+n)//2:n],ss,f,n,sss)
        
        if n-f<=1:
            if  len(s)>1:
                if (j1==0 and s2!=chr(ord(c)+1) and s2!=0) or(j2==0 and s1!=chr(ord(c)+1) and s1!=0):
                    ss+=1
                    #print(j1,s2,chr(ord(c)+1),j2,s1)


            print(ss)
            return
        c=chr(ord(c)+1)
        solve(s,f,n,ss,c)




for _ in range(int(input())):
    n=int(input())
    s=input()
    if n==1 and s!='a':
        print(1)
    elif n==1 and s=='a':
        print(0)
    else:

        ss=0
        f=0
        solve(s,f,n,ss,'a')