



def swaps(s, c):
    return sum( [ 0 if c == d else 1 for d in s ] )

def solve(n, s, c):
    if n == 1:
        return 0 if s == c else 1

    n2 = n // 2

    s1 = s[:n2]
    s2 = s[n2:]

    d = chr(ord(c)+1)

    return min( swaps(s1, c) + solve(n2, s2, d),
                swaps(s2, c) + solve(n2, s1, d) )





t = int(input().strip())

for _ in range(t):

    n = int(input().strip())

    s = input().strip()

    print( solve(n, s, 'a') )
