t=int(input())
teszt=[]
hossz=[]
def mig(h,s,c):
    alfa=['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']

    if h==1:
        if s[0]==alfa[c]:
            return 0
        else:
            return 1
    if h>1:
        s1=s[0:h//2]
        s2=s[h//2:]
        r1=0
        r2=0

        for z in s1:
            if z!=alfa[c]:
                r1+=1
        for z in s2:
            if z!=alfa[c]:
                r2+=1
        if r1>r2:
            return r2+mig(h//2,s1,(c+1)%26)
        else:
            return r1+mig(h//2,s2,(c+1)%26)
for i in range(t):
    n=int(input())
    hossz.append(n)
    eset=input()
    teszt.append(eset)
for i in range(t):
        print(mig(hossz[i],teszt[i],0))
    
