from sys import stdin


def mina(s, letter):
    if len(s) == 0:
        return(0)
    if len(s) == 1:
        if s[0] == letter:
            return(0)
        else:
            return(1)

    else:
        l = len(s)//2
        letter2 = chr(ord(letter)+1)
        L, R = s[:l], s[l:]
        #print(letter, letter2)
        costLeft = (l-L.count(letter)) + mina(R, letter2)
        costRight = (l-R.count(letter)) + mina(L, letter2)
        return(min(costLeft, costRight))
            


for _ in range(int(stdin.readline())):
    n = int(stdin.readline())
    s = stdin.readline().strip()
    
    print(mina(s, "a"))