def chekk(s,x):
    if len(s)==1:
        return int(s[0]!=x)

    mid=len(s)//2
    a=chekk(s[:mid],chr(ord(x)+1))
    a+=mid-s[mid:].count(x)

    b=chekk(s[mid:],chr(ord(x)+1))
    b+=mid-s[:mid].count(x)

    return min(a,b)

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