def hh1(x, m, c):
    return m - x.count(c)


def hh2(x, m, c):
    if m == 1:
        if x[0] == c:
            return 0
        else:
            return 1
    else:
        a = m // 2
        d = chr(1 + ord(c))
        return min(hh1(x[:a], a, c) + hh2(x[a:], a, d), hh1(x[a:], a, c) + hh2(x[:a], a, d))


for t in range(int(input())):
    n = int(input())
    s = list(input())
    print(hh2(s, n, 'a'))
