def dfs(s, b, e, c):
    if b == e:
        if s[b] == c:
            return 0
        else:
            return 1
    m = (b + e) // 2
    c1 = 0
    c2 = 0
    for i in range(b, m + 1):
        if s[i] != c:
            c1 += 1
    for i in range(m + 1, e + 1):
        if s[i] != c:
            c2 += 1
    a1 = c1 + dfs(s, m + 1, e, chr(ord(c) + 1))
    a2 = c2 + dfs(s, b, m, chr(ord(c) + 1))
    return min(a1, a2)

t = int(input())
for _ in range(t):
    l = int(input())
    s = input()
    i = 0
    print(dfs(s, 0, l - 1, 'a'))