import sys
input = sys.stdin.buffer.readline

T = int(input())

two_ch = dict()
tmp_two = 1
tmp_ch = 97
for i in range(26):
    two_ch[tmp_two] = tmp_ch
    tmp_two *= 2
    tmp_ch += 1

for testcase in range(T):
    n = int(input())
    s = list(input())
    #print(s)
    if n == 1:
        if s[0] == 97:
            print(0)
        else:
            print(1)
        continue
    
    if n == 2:
        if (s[0] == 97 and s[1] == 98) or (s[0] == 98 and s[1] == 97):
            print(0)
        elif s[0] == 97 or s[1] == 97 or s[0] == 98 or s[1] == 98:
            print(1)
        else:
            print(2)
        continue
    
    dp = [1]*n
    p = two_ch[n]
    for i in range(n):
        if s[i] == p:
            dp[i] = 0

    dis = 1

    for c in range(p-1,96,-1):
        idx = 0
        while idx < n:
            ctr1,ctr2 = 0,0
            for i in range(idx,idx+dis):
                if s[i] != c:
                    ctr1 += 1
            for i in range(idx+dis,idx+dis+dis):
                if s[i] != c:
                    ctr2 += 1

            dp[idx] = min(dp[idx]+ctr2 , dp[idx+dis]+ctr1)
            idx += dis+dis
        dis *= 2


    print(dp[0])