l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
t=int(input())
for _ in range(t):
    n=int(input())
    s=input()
    i=0
    ans=0
    while n>1:
        c1=s[:n//2].count(l[i])
        c2=s[n//2:].count(l[i])
        if c1>c2:
            ans=ans+n//2-c1
            s=s[n//2:]
            n=n//2
        elif c2>c1:
            ans=ans+n//2-c2
            s=s[:n//2]
            n=n//2
        else:
            c3=s[:n//2].count(l[i+1]) if i<25 else 0
            c4=s[n//2:].count(l[i+1]) if i<25 else 0
            if c3>c4:
                ans=ans+n//2-c1
                s=s[:n//2]
                n=n//2
            else:
                ans=ans+n//2-c1
                s=s[n//2:]
                n=n//2
        i=i+1
    if n==1 and s!=l[i]:
        ans=ans+1
    print(ans)