

def pizda(x,y,z):

    if len(s[x:y])<=1:

        if ord(s[x:y])!=z:
            return(1)
        else:
            return(0)




    else:

        a = s[x:(x+y)// 2]
        b = s[(x+y) // 2:y]
        a1 = 0
        b1 = 0
        for i in range(len(a)):
            if ord(a[i]) != z:
                a1 += 1
        for i in range(len(b)):
            if ord(b[i]) != z:
                b1 += 1
        return min(pizda(x, (x + y) // 2, z + 1)+b1, pizda((x + y) // 2, y, z + 1)+a1)


t= int(input())
for i in range (t):
    k=0
    good=ord('a')
    n=int(input())
    s=input()
    print(pizda(0,n,ord('a')))

