def f(s, m):
    c=chr(m)
    if len(s)==1:
        if s==c:
            return 0
        return 1
    n=len(s)
    return min(f(s[n//2:], m+1)+n//2-s[:n//2].count(c), f(s[:n//2], m+1)+n//2-s[n//2:].count(c))

t=int(input())
for _ in range(t):
    n=int(input())
    s=input()
    print(f(s, ord('a')))
    