def is_good(s, c):
    return s.count(c) == len(s)

def good(s, c):
    if len(s) == 1:
        return (0 if s[0] == c else 1)
    
    left = s[0:len(s)//2]
    right = s[len(s)//2:]
    moves_1 = (0 if is_good(left, c) else len(left) - left.count(c)) + good(right, chr(ord(c) + 1))
    moves_2 = (0 if is_good(right, c) else len(right) - right.count(c)) + good(left, chr(ord(c) + 1))

    return(min(moves_1, moves_2))


T = int(input())
for _ in range(T):
    N = input()
    s = input()
    print(good(s, 'a'))