
# def gcd(lft, rght):
#     if lft < rght:
#         rght, lft = lft, rght
#     if rght == 0:
#         return lft
#     return gcd(rght, lft % rght)
#
#
# def lcm(lft, rght):
#     return (lft * rght) / gcd(lft, rght)

inputs_cnt = int(input())


def get_replacements_for_good_string(string, letter):
    left_side_cnt, right_side_cnt = 0, 0
    str_len = len(string)

    if str_len == 1:
        if letter == string:
            return 0
        else:
            return 1
    str_half_len = int(str_len / 2)
    for index, str_letter in enumerate(string):
        if str_letter == letter:
            if str_half_len > index:
                left_side_cnt += 1
            else:
                right_side_cnt += 1
    return min(
        (str_half_len - left_side_cnt) +
        get_replacements_for_good_string(
            string[str_half_len:], chr(ord(letter) + 1)
        ),
        (str_half_len - right_side_cnt) +
        get_replacements_for_good_string(
            string[:str_half_len], chr(ord(letter) + 1)
        )
    )


for input_index in range(inputs_cnt):
    str_length = int(input())
    print(get_replacements_for_good_string(input(), 'a'))



