try:
    def search(a,l,r,c):
        if (len(a)==1):
            if (ord(a[0])==c):
                return(0)
            else:
                return(1)
        p=a[:r//2]
        q=a[r//2:]
        count1=0
        for i in range(len(p)):
            if (ord(p[i])==c):
                count1+=1
        s=search(q,0,len(q),c+1)
        total1=(r-l)//2-count1+s
        #print(total1,"=",(r-l)//2,"-",count1,"+",s)
        #print(p,c,"r=",r,"total1=",total1,"count1=",count1)
        count2=0
        for i in range(len(q)):
            if (ord(q[i])==c):
                count2+=1
        total2=(r-l)//2-count2+search(p,0,len(p),c+1)
        #print(q,c,"total2=",total2,"count2=",count2)
        return(min(total1,total2))

    t=int(input())
    for v in range(t):
        n=int(input())
        a=input()
        char=97
        print(search(a,0,n,97))
except:
    pass