from sys import stdin as sin

d = "abcdefghijklmnopqrstuvwxyz"

def rec(s,n,p,c):
    while n:
        if s[0:n//2].count(d[p])>s[n//2:n].count(d[p]):
            c+=(n//2-s[0:n//2].count(d[p]))
            s=s[n//2:n]
            n=n//2
            p+=1
        elif s[0:n//2].count(d[p])<s[n//2:n].count(d[p]):
            c+=(n//2-s[n//2:n].count(d[p]))
            s=s[0:n//2]
            n=n//2
            p+=1
        else:
            c+=min(
            rec(s[n//2:n],n//2,p+1,(n//2-s[0:n//2].count(d[p]))),
            rec(s[0:n//2],n//2,p+1,(n//2-s[n//2:n].count(d[p])))
            )
            break
    return c+1
for _ in range(int(sin.readline())):
    n = int(sin.readline())
    s = sin.readline()
    c=0
    p=0
    print(rec(s,n,0,0))
