alpha = "abcdefghijklmnopqrstuvwxyz"
pref = [[0 for i in range(131073)] for j in range(26)]
res = 10**8
def query(l,r,cur):
    if(l==0):
        return pref[ord(cur)-97][r]
    else:
        return pref[ord(cur)-97][r]-pref[ord(cur)-97][l-1]
def rec(s,l,r,ans,cur):
    global res,pref
    if(l==r):
        if(s[l]!=cur):
            ans+=1
        res = min(ans,res)
        return
    mid = (l+r)//2
    rec(s,mid+1,r,ans+(mid-l+1)-query(l,mid,cur),chr(ord(cur)+1))
    rec(s,l,mid,ans+(r-mid)-query(mid+1,r,cur),chr(ord(cur)+1))
for _ in range(int(input())):
    res = 10**8
    n = int(input())
    s = input()
    for i in range(26):
        for j in range(n):
            pref[i][j]=0
    for i in range(n):
        if(i>0):
            for j in range(26):
                pref[j][i]=pref[j][i-1]
        pref[ord(s[i])-97][i]+=1
    rec(s,0,n-1,0,"a")
    print(res)

