import sys
sys.setrecursionlimit(10**5)
def dp(a,ct,i,j):
    m=(i+j+1)//2
    if i>=j:return 0
    elif (i+1)==j:
        if a[i]==chr(ct) and a[j]==chr(ct+1):return 0
        elif a[i]==chr(ct+1) and a[j]==chr(ct):
            return 0
        elif (a[i]!=chr(ct) and a[j]==chr(ct+1))or(a[i]==chr(ct) and a[j]!=chr(ct+1))or(a[i]!=chr(ct+1) and a[j]==chr(ct))or(a[i]==chr(ct+1) and a[j]!=chr(ct)):
            return 1
        else:return 2
    else:   
        l,r=0,0
        for k in range(i,m):
            if a[k]!=chr(ct):
                l+=1
        for k in range(m,j+1):
            if a[k]!=chr(ct):
                r+=1
        ans=min( l+dp(a,ct+1,m,j) , r+dp(a,ct+1,i,m-1) )       
        return ans
for _ in range(int(input())):
    n=int(input())
    a=input().strip()
    if n==1:
        if a[0]=='a':print(0)
        else:print(1)
    else:
        b=dp(a,97,0,n-1)
        print(b)