def solve(n, s, c):
    ret = 0
    if n == 1:
        if s[0] == c:
            return 0
        else:
            return 1
    
    count1 =0
    count2 = 0
    s1 = s[:n//2]
    s2 = s[n//2:]
    for i in range(n//2):
        if s1[i] == c:
            count1 += 1
        if s2[i] == c:
            count2 += 1
    if count1 >= count2:
        ret += n//2-count1 + solve(n//2, s2, chr(ord(c)+1))
    else:
        ret += n//2-count2 + solve(n//2, s1, chr(ord(c)+1))
    return ret
    

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