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

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

    # return min(half - first.count(letter) + g)

    return min(half - first.count(letter) + good(second, chr(ord(letter) + 1)), half - second.count(letter) + good(first, chr(ord(letter) + 1)))
    
    
    # print(good_greedy('z', 'a'))
total = int(input())
for _ in range(total):
    len_n = input()
    original = input().strip()

    # print(original)

    # print(good_greedy(original, 'a'))
    print(good(original, 'a'))