from collections import defaultdict

t=int(input())
for _ in range(t):
    n=int(input())
    s=input()
    z="abcdefghijklmnopqrstuvwxyz"
    
    d={}
    d=defaultdict(lambda:[],d)
    
    cnt=0
    x=n//2
    
    i=0
    d[z[i]].append(s)
    #print(cnt,z[i],s,x)
    while x>=1 and i<26:
        maxz=0
        while len(d[z[i]])!=0:
            ss = d[z[i]].pop(0)
            q=len(ss)
            s1=ss[:q//2].count(z[i])
            s2=ss[q//2:].count(z[i])
           # print(ss,s1,s2,z[i])
            if s1>s2:
                if maxz<s1:
                    d[z[i+1]]=[ss[q//2:]]
                    maxz=s1
                elif maxz==s1:
                    d[z[i+1]].append(ss[q//2:])
            elif s2>s1:
                if maxz<s2:
                    d[z[i+1]]=[ss[:q//2]]
                    maxz=s2
                elif maxz==s2:
                    d[z[i+1]].append(ss[:q//2])
            else:
                if maxz<s1:
                    d[z[i+1]]=[ss[q//2:],ss[:q//2]]
                    maxz=s1
                elif maxz==s1:
                    d[z[i+1]].append(ss[q//2:])
                    d[z[i+1]].append(ss[:q//2])
            
        cnt+=x-maxz
        x=x//2
        i+=1
        #print(d)
        #print(cnt,x,z[i],maxz)
    
    if d[z[i]][0]!=z[i]:
        cnt+=1
    print(cnt)
            
        