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