def recur(s,ch,n):
    if not n:
        return 0
    elif n==1:
        return 0 if chr(ch)==s else 1
    else:
        f=s[:n//2]
        l=s[n//2:]
        
        return min((n//2-f.count(chr(ch)))+recur(l,ch+1,n//2),(n//2-l.count(chr(ch)))+recur(f,ch+1,n//2))
for _ in range(int(input())):
    n=int(input())
    st=input()
    print(recur(st,ord('a'),n))