def get(s,a):
    if len(s)==1:
        return int(a!=s)
    q=[0,0]
    for i in range(len(s)):
        q[i*2//len(s)]+=s[i]==a
    return min(len(s)//2-q[0]+get(s[len(s)//2:],chr(ord(a)+1)),len(s)//2-q[1]+get(s[:len(s)//2],chr(ord(a)+1)))
for _ in range(int(input())):
    n=input()
    print(get(input(),'a'))