from sys import stdin as sin

d = "abcdefghijklmnopqrstuvwxyz"

def rec(s,n,p):
    if n==1:
        if d[p]==s:
            return 0
        else:
            return 1
    else:

        return min(
                (n//2-s[0:n//2].count(d[p]))+rec(s[n//2:n],n//2,p+1,),
                (n//2-s[n//2:n].count(d[p]))+rec(s[0:n//2],n//2,p+1,)
                )
for _ in range(int(sin.readline())):
    n = int(sin.readline())
    s = sin.readline()
    c=0
    p=0
    print(rec(s,n,0))
