t=int(input())


for x in range(t):
    n=input()
    s=input()


    def check(s,i):
        
        cnt=0
        for j in s:

            if j!=chr(ord('a')+i):

                cnt=cnt+1
        return(cnt)

    def fun(s,i):

        mid=len(s)//2

        if len(s)==1 and s==chr(ord('a')+i):

            return(0)

        elif len(s)==1:

            return(1)

        
        elif check(s[:mid],i)==0:

            return(fun(s[mid:],i+1))

        elif check(s[mid:],i)==0:

            return(fun(s[:mid],i+1))

        else:

            k=min(check(s[mid:],i)+fun(s[:mid],i+1),check(s[:mid],i)+fun(s[mid:],i+1))
            return(k)
            

    print(fun(s,0))
            
            

        
        
