import sys
input = sys.stdin.readline

t = int(input())

def distance(s, c):
    m = len(s)
    if m == 1:
        return int(s != c)
    else:
        left_good = distance(s[0:m//2], chr(ord(c) + 1))
        right_good = distance(s[m//2:], chr(ord(c) + 1))
        left_distance = sum([c != i for i in s[0:m//2]])
        right_distance = sum([c != i for i in s[m//2:]])
        dist = min(left_good + right_distance, right_good + left_distance)
        return dist

for _ in range(t):
    n = int(input())
    input_string = ''.join(input().split())
    print(distance(input_string, 'a'))
