total = int(input())


def good_greedy(s, letter):
    if len(s) == 1:
        if s == letter:
            return 0
        else:
            return 1

    half = len(s) // 2
    first = s[:half]
    second = s[half:]

    if first.count(letter) > second.count(letter):
        return half - first.count(letter) + good_greedy(second, chr(ord(letter) + 1))
    elif first.count(letter) == second.count(letter):
        return min(half - first.count(letter) + good_greedy(second, chr(ord(letter) + 1)), half - second.count(letter) + good_greedy(first, chr(ord(letter) + 1)))
    else:
        return half - second.count(letter) + good_greedy(first, chr(ord(letter) + 1))


# print(good_greedy('z', 'a'))

for _ in range(total):
    len_n = input()
    original = input().strip()

    # print(original)

    print(good_greedy(original, 'a'))