def fun(s,ch):
    if len(s)==1:
        return(int(s!=ch))
        
    mid=len(s)//2
    
    left=s[:mid]
    left_count=left.count(ch)
    
    right=s[mid:]
    right_count=right.count(ch)
    
    nxt=chr(ord(ch)+1)
    
    return(min(mid-left_count+fun(right,nxt),mid-right_count+fun(left,nxt)))


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