def code(start,end,l,letter):
    ans=0
    if(start!=end):
        mid=start+(end-start-1)//2
        arr1=l[start:mid+1]
        arr2=l[mid+1:end+1]
        arr1_count=arr2_count=0
        mini=len(arr1)
        for i in range(mini):
            if(arr1[i]==chr(letter)):
                arr1_count+=1
            if(arr2[i]==chr(letter)):
                arr2_count+=1
        ans1=mini-arr1_count+code(mid+1,end,l,letter+1)
        ans2=mini-arr2_count+code(start,mid,l,letter+1)
        return min(ans1,ans2)
    elif(l[start]!=chr(letter)):
        ans+=1
    return(ans)
    
t=int(input(""))
while t>0:
    n=int(input(""))
    l=input("")
    start=0
    end=n-1
    letter=97
    ans=0
    #print(l)
    print(code(start,end,l,letter))
    t-=1
 