ans=[1000000]
def helper(present,s,start,end,letter):
    
    if start>=end:
        if s[start]!=letter:
            
            present+=1
        ans[0]=min(ans[0],present)    
        return    
        
        
    else:
        mid=start+(end-start)//2
        left=0
        right=0
        for i in range(start,mid+1):
            
            if s[i]!=letter:
                left+=1
        for i in range(mid+1,end+1):
            if s[i]!=letter:
                right+=1

        helper(present+left,s,mid+1,end,chr(ord(letter)+1))      
        helper(present+right,s,start,mid,chr(ord(letter)+1))              



z=[]

t=int(input())
for _ in range(t):
    n=int(input())
    
    ans[0]=n
    s=input()
    helper(0,s,0,n-1,'a')
    z.append(ans[0])

for i in range(t):
    print(z[i])


