def solve(l,c):
    cc=chr(c)
    if len(l)==1:
        return( 1 if l[0]!=cc else 0)
    k=len(l)//2 
    l1=k-l[:k].count(cc)+solve(l[k:],c+1)
    l2=k-l[k:].count(cc)+solve(l[:k],c+1)
    return(min(l1,l2))
    

for _ in range(int(input())):
    n=int(input())
    s=input()
    print(solve(s,ord('a')))