def solve(start, stop, n, i, m):
    global r
    x = chr(i)
    if n:
        solve(start, start + n, int(n / 2), i + 1, m + n - s.count(x, start + n, stop))
        solve(start + n, stop, int(n / 2), i + 1, m + n - s.count(x, start, start + n))
    else:
        m += 1 - s.count(x, start, stop)
        r.append(m)


for _ in range(int(input())):
    n = int(input())
    s = input()
    r = []
    solve(0, n, int(n / 2), 97, 0)
    print(r)
    print(min(r))
