def solve(s,c):
    if len(s) == 0:
        return 0
    if len(s) == 1:
        if s[0] == c:
            return 0
        else:
            return 1

    n = len(s)

    first = n//2-s[0:n//2].count(c)
    second = n//2-s[n//2:].count(c)
    
    return min(solve(s[n//2:],chr(ord(c)+1))+first,solve(s[:n//2],chr(ord(c)+1))+second)




from collections import defaultdict
t = int(input())
for _ in range(t):
    n  = int(input())
    s = input()


    print(solve(s,'a'))
