def f(s, c):
    if len(s) == 1:
        return int(s[0] != c)
    n = len(s)
    return min(n//2 - s[:n//2].count(c) + f(s[n//2:], chr(ord(c)+1)),
               n//2 - s[n//2:].count(c) + f(s[:n//2], chr(ord(c)+1)))

t = int(input())
for _ in range(t):
    n = int(input())
    s = input()
    print(f(s, 'a'))