def search(arr,total,val):
    if len(arr) > 1:
        count=0
        for i in range(len(arr)//2,len(arr)):
            if arr[i]==chr(val):
                count+=1
                
        count1=0
        for i in range(0,len(arr)//2):
            if arr[i]==chr(val):
                count1+=1
        if count1 >= count:
            total+=(len(arr)//2-count1)
            #print(arr,total)
            return search(arr[len(arr)//2:len(arr)],total,val+1)
        else:
            #print(arr,total)
            total+=(len(arr)//2-count)
            return search(arr[0:len(arr)//2],total,val+1)
    else:
        #print(arr,total)
        if arr[0]==chr(val):
            return total
        else:
            return total+1
            
t=int(input())
for _ in range(t):
    n=int(input())
    s=input().rstrip("\n")
    s=list(s)
    if len(s) == 1:
        if s[0] == "a":
            print("0")
        else:
            print("1")
    else:
        print(search(s,0,ord("a")))
        
    
        