def fun(st,c):
    le=len(st)
    if(le==1):
        if(st[0]==c):
            return 0
        else:
            return 1
    xx=0
    for i in st[0:le//2]:
        if(i==c):
            xx+=1
    xx=le//2-xx
    yy=0
    for i in st[le//2:le]:
        if(i==c):
            yy+=1
    yy=le//2-yy
    ans=min(xx+fun(st[le//2:],chr(ord(c)+1)),yy+fun(st[0:le//2],chr(ord(c)+1)))
    return ans
for _ in range(int(input())):
    n=int(input())
    st=input()
    print(fun(st,'a'))
        