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))


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


        