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
    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:
        steps += calc_steps_c_good(end_string, letter_code + 1, mid)
    else:
        steps += calc_steps_c_good(start_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))