import sys
mass=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r']
take=1024
ops=[]
a=''
def gen1(n,l,r,cur,string,res):
    if r-l>1:
        
        res1=res
        r1=r
        l1=(r+l+1)//2
        while l1<=r1:
            if string[l1]!=mass[cur]:
                res1+=1
            l1+=1
        
        gen1(n//2,l,(l+r+1)//2-1,cur+1,string,res1)
        res1=res
        
        r1=(r+l+1)//2-1
        l1=l
        while l1<=r1:
            if string[l1]!=mass[cur]:
                res1+=1
            l1+=1
       
        gen1(n//2,(l+r+1)//2,r,cur+1,string,res1)
    else:
        if string[l:r+1]==mass[cur]+mass[cur+1]:
            res+=0
        elif string[l:r+1]==mass[cur+1]+mass[cur]:
            res+=0
        elif string[l]==mass[cur] or string[l]==mass[cur+1]:
            res+=1
        elif string[r]==mass[cur]or string[r]==mass[cur+1]:
            res+=1
        else:
            res+=2
        global take
        if res<take:
            take=res
        return
        
        
    
    
    
#q=1
q=int(input())
for i in range(q):
    #n,m=[int(j) for j in sys.stdin.readline().split()]
    n=int(sys.stdin.readline())
    #a=[int(j) for j in sys.stdin.readline().split()]
    a=sys.stdin.readline().strip()
    #a='a'*4
    take=n
    gen1(n,0,n-1,0,a,0) #gen1(n,l,r,cur,string,res):
    print(take)
    
    
    
                
        
        


