def good_string(word, length, single):
    if length == 1:
        if (word != single):
            return 1
        else:
            return 0

    single_2 = chr(1 + ord(single))
    n = int(length / 2)

    first_word = word[:n]
    last_word = word[n:]
    single_2 = chr(1 + ord(single))

    res_1 = len(first_word) - first_word.count(single) + \
        good_string(last_word, len(last_word), single_2)
    res_2 = len(last_word) - last_word.count(single) + \
        good_string(first_word, len(first_word), single_2)

    return min(res_1, res_2)


total = int(input())
for i in range(total):
    length = int(input())
    word = input()
    print(good_string(word, length, 'a'))
