def goodString(s, a, i, j):
    if i == j:
        return 0 if s[i] == a else 1

    mid = (i + j) // 2
    #left half
    d1 = 0
    for k in range(i, mid + 1):
        d1 += (1 if s[k] != a else 0)
    d1 += goodString(s, chr(ord(a) + 1), mid + 1, j)

    # right half
    d2 = 0
    for k in range(mid + 1, j + 1):
        d2 += (1 if s[k] != a else 0)
    d2 += goodString(s, chr(ord(a) + 1), i, mid)

    return min(d1, d2)

for _ in range(int(input())):
    n = int(input())
    s = list(input())
    print(goodString(s, 'a', 0, n - 1))
    