def dfs(l,r,c,s):
    if len(s)==1:
        return (s[0]==c)^1
    mid=(l+r)//2
    L,R=s[:mid],s[mid:]
    lC,rC=len(L)-L.count(c),len(R)-R.count(c)
    ans1=lC+dfs(0,mid,chr(ord(c)+1),R)
    ans2=rC+dfs(0,mid,chr(ord(c)+1),L)
    return min(ans1,ans2)

def solve():
    n=int(input())
    s=input()
    ans=dfs(0,n,'a',s)
    print(ans)


t=int(input())
for _ in range(t):
    solve()