def isGoodString(s,n,c,ans):
    if(n == 1):
        if(s[0]!=c):
            ans +=1 
        return ans
    staage = s[:n//2]
    aage = n//2 - staage.count(c)
    stpiche = s[n//2:]
    piche = n//2 - stpiche.count(c)
    
    return min(isGoodString(s[n//2:],n//2,chr(ord(c)+1),ans+aage),isGoodString(s[:n//2],n//2,chr(ord(c)+1),ans+piche))



for _ in range(int(input())):
    n = int(input())
    s = input()
    ans = 0
    if(n==1):
        if(s!='a'):
            ans = 1
    else:
        ans = isGoodString(s,n,'a',0)
    
    print(ans)
