def solve(s,x,size,ans):
    if size==1: 
        if s[0]!=x:
            ans += 1
        return ans

    l = s[:size//2].count(x)
    r = s[size//2:].count(x)

    return min(size//2-l + solve(s[size//2:],chr(ord(x)+1),size//2,ans), \
        size//2-r + solve(s[:size//2],chr(ord(x)+1),size//2,ans))
    
    
    # if l>r:
    #     ans[0] += size//2-l
    #     x = chr(ord(x)+1)
    #     solve(s[size//2:],x,size//2,ans)
    # elif l<r:
    #     ans[0] += size//2-r
    #     x = chr(ord(x)+1)
    #     solve(s[:size//2],x,size//2,ans)
    # else:
    #     ll = s[:size//2].count(chr(ord(x)+1))
    #     rr = s[size//2:].count(chr(ord(x)+1)) 
    #     if ll>rr:
    #         ans[0] += size//2-r
    #         x = chr(ord(x)+1)
    #         solve(s[:size//2],x,size//2,ans)
    #     else:
    #         ans[0] += size//2-l
    #         x = chr(ord(x)+1)
    #         solve(s[size//2:],x,size//2,ans)

for _ in range(int(input())):
    n = int(input())
    s = input()
    # ans = [0]
    print(solve(s,"a",n,0))
    # print(ans[0])

        
