t=int(input())

def string_change(s,character):
    temp1,temp2=0,0
   
    if(len(s)==1 and s[0]==character):
        return 0
    if( len(s)==1 and s[0]!=character):
        return 1
       
   
    for i in range(len(s)//2):
        if s[i]==character:
            temp1+=1
   
    for i in range(len(s)//2,len(s)):
        if s[i]==character:
            temp2+=1
    n= len(s)
    next_char= chr(ord(character)+1)
   
    if(temp1>temp2):
        #return (((len(s)//2) - temp1)+ string_change(s[(n//2):], next_char))
        return min(((n//2)-temp1) +string_change(s[(n//2):], next_char), ((n//2)-temp2) +string_change(s[:(n//2)], next_char))
   
    elif(temp2>temp1):
        #return (((len(s)//2) - temp2)+ string_change(s[:(n//2)], next_char))
        return min(((n//2)-temp1) +string_change(s[(n//2):], next_char), ((n//2)-temp2) +string_change(s[:(n//2)], next_char))
   
    else:
       return min(((n//2)-temp1) +string_change(s[(n//2):], next_char), ((n//2)-temp2) +string_change(s[:(n//2)], next_char))
   
       
       
   

for _ in range(t):
    n=int(input())
    s= str(input())
    print(string_change(s,'a'))