def rec(s,c):
    l=len(s)
    if l==1 and s==chr(c):
        return 0
    elif l==1 and s!=chr(c):
        return 1
    return min(l//2-s[l//2:l].count(chr(c))+rec(s[0:l//2],c+1),l//2-s[0:l//2].count(chr(c))+rec(s[l//2:l],c+1))
for _ in range(int(input())):
    n=int(input())
    s=input()
    print(rec(s,97))