ALPHA = "abcdefghijklmnopqrstuvwxyz"



def toGood(i, s):
    l = ALPHA[i]
    if len(s) == 1:
        if s != l:
            return 1
        else:
            return 0
    left = 0
    right = 0
    for letter in s[:len(s)//2]:
        if letter != l:
            left += 1
    for letter in s[len(s)//2:]:
        if letter != l:
            right += 1
    return min(left + toGood(i+1, s[len(s)//2:]),
                right + toGood(i+1, s[:len(s)//2:]))
        
        


T = int(input())
for _ in range(T):
    N = int(input())
    S = input()
    print(toGood(0, S))
    
