def movestomakecgood(c, s):
    if len(s) == 1:
        return int(s != c)
    return min(
        sum(x != c for x in s[len(s)//2:]) +
        movestomakecgood(chr(ord(c)+1), s[:len(s)//2]),
        movestomakecgood(chr(ord(c)+1), s[len(s)//2:]) +
        sum(x != c for x in s[:len(s)//2])
    )


def solve(s):
    return movestomakecgood('a', s)


for _ in range(int(input())):
    n = int(input())
    s = input().rstrip()
    print(solve(s))
