A="abcdefghijklmnopqrstuvwxyz"
def fun(s,i):
    k=len(s)
    c=A[i]
    if(k==1):
        if(s[0]==c):
            return 0
        return 1    
    t1=s[:(k//2)].count(c)
    t2=s[k//2:].count(c)
    
    return min((k//2)-t2+fun(s[:k//2],i+1),(k//2)-t1+fun(s[k//2:],i+1))


for _ in range(int(input())):
    n=int(input())
    s=input()
    
    print(fun(s,0))