def Count1(string, char, n):
    return n - string.count(char)

def Count(string, char, n):
    if n == 1:
        if string == char: return 0
        else: return 1
    else:
        a = Count1(string[: n//2], char, n//2) + Count(string[n//2: ], chr(ord(char)+1), n//2)
        b = Count(string[: n//2], chr(ord(char)+1), n//2) + Count1(string[n//2: ], char, n//2)
        return min(a, b)

for _ in range(int(input())): 
    n = int(input())
    string = input()
    print(Count(string, 'a', n))