def yes(s,n,lett):
    z=lett
    lett=chr(ord(lett)+1)
    if n==1:
        if z==s:
            return 0
        else:
            return 1
    x=s[:n//2]
    y=s[n//2:]
    cx=n//2-x.count(z)
    cy=n//2-y.count(z)
    out=0
    out+=min((cy)+yes(x,n//2,lett),(cx)+yes(y,n//2,lett))
    '''if cy<cx:
        out+=(cy)+yes(x,n//2,lett)
    else:
        out+=(cx)+yes(y,n//2,lett)'''
    return out
        
        

t=int(input())
while t:
    t=t-1
    n=int(input())
    s=input()
    print(yes(s,n,'a'))
