from sys import stdin
input = stdin.readline

from collections import defaultdict
def solve(i, j, c, ans, mini = 200000):
    #print(i, j, c, ans)
    if j == i:
        #print(s[i-1],c,ans)
        if s[i-1]!=c:
            ans+=1
        return min(ans, mini)
    
    
    first = i - 1 + (j - i + 1) // 2
    amt = (j - i + 1) // 2
    req = amt - (d[first][c] - d[i - 1][c])
    mini = min(mini, solve(first + 1, j, chr(ord(c)+1), ans + req))
    
    req = amt - (d[j][c] - d[first][c])
    mini = min(mini, solve(i, first, chr(ord(c)+1), ans + req))
    
    return mini
    
for _ in range(int(input())):
    n = int(input())
    s = input().strip()
    t = defaultdict(int)
    d = [t.copy()]
    for i in range(n):
        t[s[i]]+=1
        d.append(t.copy())
    
    res = solve(1, n, 'a', 0)
    print(res)