def solution(s,l,r,c):
    if r-l==1:
        if s[l]==chr(c):
            return 0
        return 1
    else:
        mid=(l+r)//2
        x=solution(s,l,mid,c+1)
        x+=(mid-l)-s[mid:r].count(chr(c))
        y=solution(s,mid,r,c+1)
        y+=(r-mid)-s[l:mid].count(chr(c))
        return min(x,y)
t=int(input())
for i in range(t):
    n=int(input())
    s=str(input())
    print(solution(s,0,n,97))
        