import sys
INP = lambda: sys.stdin.readline().strip()
INT = lambda: int(INP())
MAP = lambda: map(int, INP().split())
ARR = lambda: [int(i) for i in INP().split()]
def JOIN(arr, x=' '): return x.join([str(i) for i in arr])
def EXIT(x='NO'): print(x); exit()

def solve(n,s,c='a'):
    if n==1: return int(s!=c)
    m,d = n//2,chr(ord(c)+1)
    l,r = s[:m].count(c),s[m:].count(c)
    return min(m-l+solve(m,s[m:],d), m-r+solve(m,s[:m],d))


for _ in range(INT()):
    n = INT()
    s = INP()
    print(solve(n,s))