import sys
#sys.setrecursionlimit(10**6) 

def calc(l, r, c, s):
    if abs(l - r) < 1:
        if s[l] == c:
            return 0
        else:
            return 1
    else:
        m = (l + r) // 2
        if l == m:
            count1 = 1 if s[l] != c else 0
            count2 = 1 if s[r] != c else 0
        else:
            count1, count2 = 0, 0
            for i in range(l, m+1):
                if s[i] != c:
                    count1 += 1
            for i in range(m+1, r+1):
                if s[i] != c:
                    count2 += 1
        ans1 = count1 + calc(m+1, r, chr(ord(c)+1), s)
        ans2 = count2 + calc(l, m, chr(ord(c)+1), s)
        return min(ans1, ans2)
        
    

def solve(n, s):
    print(calc(0, n-1, 'a', s))
    
t = int(input())
for i in range(t):
    n = int(input())
    s = input()
    solve(n, s)
