def solve(n, s, c):
    if n == 1:
        return 1 if s[0] != c else 0
    half1 = s[:n//2].count(c)
    half1Total = n//2 - half1 + solve(n//2, s[n//2:], c+1)
    half2 = s[n//2:].count(c)
    half2Total = n//2 - half2 + solve(n//2, s[:n//2], c+1)
    return min(half1Total, half2Total)

for _ in range(int(input())):
    n = int(input())
    s = list(input())
    for i in range(n):
        s[i] = ord(s[i]) - 97
    print(solve(n, s, 0))