def solve(s, c):
    n = len(s)
    if n==1:
        if s[0]==c:
            return 0
        else:
            return 1
    l = n//2 - s[:n//2].count(c) + solve(s[n//2:], chr(ord(c)+1))
    r = n//2 - s[n//2:].count(c) + solve(s[:n//2], chr(ord(c)+1))
    return min(l, r)

t = int(input())
for _ in range(t):
    input() 
    print(solve(input(), 'a'))