alf="abcdefghijklmnopqrstuvwxyz"


def solve(s,l,r,z):
    if r - l == 1:
        if s[l] == alf[z]:
            return 0
        else:
            return 1
    else:
        m=(l+r)//2
        return min(solve(s,l,m,z+1)+(r-l)//2 -s[m:r].count(alf[z]),
                   solve(s,m,r,z+1)+(r-l)//2 -s[l:m].count(alf[z]))



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