def getcost(st,e,c):
    cnt=0
    for i in range(st,e):
        if(s[i]!=c):
            cnt+=1
    return cnt
def getmin(start,end,ch):
    if(start==end-1):
        return 0 if s[start]==ch else 1
    mid=(start+end)//2
    return min(getcost(start,mid,ch)+getmin(mid,end,chr(ord(ch)+1)),getcost(mid,end,ch)+getmin(start,mid,chr(ord(ch)+1)))
t=int(input())
for _ in range(t):
    n=int(input())
    s=input()
    print(getmin(0,n,'a'))
