def cost(a, b):
    return 0 if a == b else 1


def constrit(strg, char='a'):
    l = len(strg)
    if l == 1:
        return 0 if strg == char else 1
    newchar = chr(ord(char)+1)

    return min(constrit(strg[:l//2], newchar) + sum(map(lambda x: 0 if x == char else 1, strg[l//2:])),
               constrit(strg[l//2:], newchar) + sum(map(lambda x: 0 if x == char else 1, strg[:l//2])))


def process():
    n = int(input())
    strg = input()
    print(constrit(strg))


for i in range(int(input())):
    process()
