def check(string, ch, n):
    #print("string: ", string, " ch: ", ch, " n:", str(n))
    if n == 1:
        if string == ch:
            return 0
        else:
            return 1

    half = n//2;
    #print("half: ", half)

    op1 = (check(string[0:half], chr(ord(ch)+1), half) + fix(string[half:], ch, half)) 
    op2 = (fix(string[0:half], ch, half) + check(string[half:], chr(ord(ch)+1), half))

    return min(op1, op2)

def fix(string, ch, n):
    counter = 0
    for x in string:
        if x != ch:
            counter += 1
    return counter

t = int(input())

for i in range(t):
    n = int(input())

    string = input()

    print(check(string, 'a', n))

