def good_str(s,x,n):
    if n==1:
        if s[0]==chr(x):
            return 0
        else:
            return 1
    else:
        s1 = s[:n//2]
        s2 = s[n//2:]
        p = s1.count(chr(x))
        q = s2.count(chr(x))
        sum1 = (n//2-p)+good_str(s2,x+1,n//2)
        sum2 = (n//2-q)+good_str(s1,x+1,n//2)
        return min(sum1,sum2)
    
for _ in range(int(input())):
    n = int(input())
    s = input()
    result = good_str(s,97,n)
    print(result)