def calc_steps_c_good(string: str, letter_code: int, length: int) -> int:
    if length == 1:
        if string == chr(letter_code):
            return 0
        return 1
    steps = 0
    mid = length >> 1
    new_string = start_string = string[:mid]
    end_string = string[mid:]
    start_ct = start_string.count(chr(letter_code))
    end_ct = end_string.count(chr(letter_code))
    if start_ct == end_ct:
        start_w = sum([ord(x) for x in start_string])
        end_w = sum([ord(x) for x in end_string])
        if start_w >= end_w:
            new_string = end_string
    elif start_ct > end_ct:
        new_string = end_string
    steps += calc_steps_c_good(new_string, letter_code + 1, mid)
    steps += mid - max(start_ct, end_ct)
    return steps


for _ in range(int(input())):
    l = int(input())
    value = input()
    print(calc_steps_c_good(value, ord('a'), l))