def solve(c,l,h,s):
    c = chr(c)
    if l==h:
        return int(s[l]!=c)
    k = h - l + 1
    cc = 0
    for i in range(l,l + k//2):
        if s[i]!=c:
            cc+=1
    kk = cc + solve(ord(c)+1,l+k//2,h,s)
    cc = 0
    for i in range(l+k//2,h+1):
        if s[i]!=c:
            cc+=1
    pp = cc+solve(ord(c)+1,l,l+k//2 -1,s)
    return min(pp,kk)
for _ in range(int(input())):
    n = int(input())
    s = input()
    print(solve(ord('a'),0,n-1,s))
