def get_next_char(char):
    return chr(ord(char) + 1)


def solve(string, size, char="a"):
    if (len(string) == 1):
        if (string[0] == char):
            return 0
        return 1

    half_size = size // 2
    fst_half = string[0:half_size]
    snd_half = string[half_size:]

    moves_on_left = half_size - fst_half.count(char)
    moves_on_right = half_size - snd_half.count(char)

    left = moves_on_left + solve(snd_half, half_size, get_next_char(char))
    right = moves_on_right + solve(fst_half, half_size, get_next_char(char))

    return min(left, right)


for _ in range(int(input())):
    size = int(input())
    string = list(input())

    print(solve(string, size))
