def two(s, r, n):
    if n == 1:
        t = 1 - s.count(chr(r))
        return t
    a = s[:n//2]
    b = s[n//2:]
    t = n//2-a.count(chr(r))+two(b, r+1, n//2)
    m = n//2-b.count(chr(r))+two(a, r+1, n//2)
    return min(t, m)
for _ in range(int(input())):
    n = int(input())
    s = input()
    r = 97
    print(two(s, r, n))