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


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