def get_steps_all(string, x):
    n = 0
    for a in string:
        if a != x:
            n += 1
    # print(string, "all", x)
    # print(n)
    # print("========")
    return n


def get_steps_good(string, x):
    if len(string) == 1:
        if string[0] == x:
            # print(string, "good", x)
            # print(0)
            # print("========")
            return 0
        else:
            # print(string, "good", x)
            # print(1)
            # print("========")
            return 1
    mid = int(len(string) / 2)
    result = min(get_steps_all(string[:mid], x) + get_steps_good(string[mid:], chr(ord(x) + 1)),
                 get_steps_good(string[:mid], chr(ord(x) + 1)) + get_steps_all(string[mid:], x))
    # print(string, "good", x)
    # print(result)
    # print("========")
    return result
    # return min(get_steps(string[:mid], x) + get_steps(string[mid:], chr(ord(x)+1)),
    #            get_steps(string[:mid], chr(ord(x)+1)) + get_steps(string[mid:], x))


n_cases = int(input())
for i in range(0, n_cases):
    length = int(input())
    input_string = input()
    print(get_steps_good(input_string, "a"))
