#https://codeforces.com/problemset/problem/1385/D

testCases = int(input())
letters = "abcdefghijklmnopqrstuvwxyz"


def offset(string, char):
    ret = 0
    if char in string:
        for k in range(len(string)):
            if string[k] == char:
                ret += 1
    return ret


def good_count(string, char):
    length = len(string)
    wanted_char = letters[char]

    if length == 0:
        return 0
    elif length == 1:
        if wanted_char in string:
            return 0
        else:
            return 1

    #Data
    half_len = int(length / 2)
    first_half = string[0: half_len]
    second_half = string[half_len: length]

    fhalf_offset = offset(first_half, wanted_char)
    shalf_offset = offset(second_half, wanted_char)

    #Solving
    return min(half_len - fhalf_offset + good_count(second_half, char + 1), half_len - shalf_offset + good_count(first_half, char + 1))

for x in range(testCases):
    input()
    print(good_count(input(), 0))