from collections import Counter
def rec(s,n,y):
    out=0
    if n>1:
        p=Counter(s[:n//2])[chr(97+y)]
        q=Counter(s[n//2:])[chr(97+y)]
        out+=min(rec(s[n//2:],n//2,y+1)+n//2-p,rec(s[:n//2],n//2,y+1)+n//2-q)
    else:
        if s!=chr(y+97):
            out+=1
    return out
for _ in range(int(input())):
    n=int(input())
    s=input()
    if n>1:
        ans=0
        p=Counter(s[:n//2])['a']
        q=Counter(s[n//2:])['a']
        ans+=min(n//2-p+rec(s[n//2:],n//2,1),n//2-q+rec(s[:n//2],n//2,1))
        print(ans)
    else:
        if s!='a':
            print(1)
        else:
            print(0)