def next(c):
    return chr(97+(ord(c)-96)%26)

def find(s,c):
    if len(s)==1:
        return 1-(s[0]==c)
    cl,cr=0,0
    for i in range(len(s)//2):
        cl+=1-(s[i]==c)
    for i in range(len(s)//2,len(s)):
        cr+=1-(s[i]==c)
    return min(cl+find(s[len(s)//2:len(s)],next(c)),cr+find(s[0:len(s)//2],next(c)))

for _ in range(int(input())):
    n=int(input())
    s=input()
    print(find(s,'a'))
