t=int(input())
def makegood(string,num):
    s = chr(num)
    m = len(string)
    if m==1:
        if string[0]!=s:
            return 1
        else:    
            return 0    
    st1=string[:m//2]
    st2=string[m//2:]
    check1=m//2-st1.count(s)+makegood(st2,num+1)
    check2=m//2-st2.count(s)+makegood(st1,num+1)

        
    
    return min(check1,check2)    


for i in range(t):
    n=int(input())
    string=input()
    print(makegood(string,97))




    