def agoodString(s,c):
    if len(s)==1:
        if s[0]==c:
            return 0
        else:
            return 1
    
    mid = len(s)//2
    cntl = agoodString(s[:mid],chr(ord(c)+1))
    cntl+=len(s)//2 - s[mid:].count(c)
    cntr = agoodString(s[mid:],chr(ord(c)+1))
    cntr+=len(s)//2 - s[:mid].count(c)
    return min(cntl,cntr)


t = int(input())

for _ in range(t):
    n = int(input())
    s = input()
    print(agoodString(s,"a"))