from sys import stdin, setrecursionlimit
setrecursionlimit(100000)
input = stdin.readline

def solve(s, c):
    if len(s) == 1:
        if s[0] == chr(c + ord("a")):
            return 0
        else:
            return 1
    current = 0
    for i in range(len(s) // 2):
        if s[i] != chr(c + ord("a")):
            current += 1
    a = solve(s[len(s) // 2:], c + 1) + current
    current = 0
    for i in range(len(s) // 2, len(s)):
        if s[i] != chr(c + ord("a")):
            current += 1
    b = solve(s[:len(s) // 2], c + 1) + current
    return min(a, b)

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