def count(s, c):
    tot = 0
    for char in s:
        if char == c: tot += 1
    return tot 

def solve(n, s, c):
    if n == 1:
        if s == c:
            return 0
        else:
            return 1
    count_1 = len(s)//2 - count(s[:len(s)//2], c) + solve(n//2, s[len(s)//2:], chr(ord(c)+1))
    count_2 = len(s)//2 - count(s[len(s)//2:], c) + solve(n//2, s[:len(s)//2], chr(ord(c)+1))
    return min(count_1, count_2)
        

t = int(input())
for case in range(1, t+1):
    n = int(input())
    s = input()
    print(solve(n, s, 'a'))