def func(i,j,t):
    global l 
    if(i==j):
        if(l[t]==s[i]):
            return 0
        else:
            return 1
    elif(j==i+1):
        x=0
        y=0
        if(s[i]==l[t]):
            x+=1
        if(s[j]==l[t]):
            y+=1
        return min(1-x+func(j,j,t+1),1-y+func(i,i,t+1))
    else:
        mid=(i+j)//2 
        if(i==0):
            return min((j-i+1)//2-d[l[t]][mid]+func(mid+1,j,t+1),(j-i+1)//2-(d[l[t]][j]-d[l[t]][mid-1])+func(i,mid,t+1))
        return min((j-i+1)//2-(d[l[t]][mid]-d[l[t]][i-1])+func(mid+1,j,t+1),(j-i+1)//2-(d[l[t]][j]-d[l[t]][mid-1])+func(i,mid,t+1))
for w in range(int(input())):
    n=int(input())
    s=str(input())
    l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    d={}
    for i in l:
        d[i]=[0]*n
    for i in l:
        for j in range(n):
            if(j==0):
                if(s[j]==i):
                    d[i][j]=1
                else:
                    d[i][j]=0
            elif(s[j]==i):
                d[i][j]=d[i][j-1]+1
            else:
                d[i][j]=d[i][j-1]
    print(func(0,n-1,0))