def good(x, c):
    if(len(x)==1):
        return x[0]!=c
    mid = int(len(x)/2)
    cntl = good(x[:mid], chr(ord(c) + 1))
    cntl+= int(len(x)/2) - x[mid:len(x)].count(c)
    cntr = good(x[mid:len(x)], chr(ord(c) + 1))
    cntr+= int(len(x)/2) - x[:mid].count(c)
    return min(cntr, cntl)

n = int(input())

for i in range(n):
    y = int(input())
    x = str(input())
    c = "a"
    if(len(x)==1):
        if(x[0]!='a'):
            print("1")
            continue
        else:
            print("0")
            continue
    print(good(x, c))