def mc(s, i=0, j=None, c='a'):
    if j is None:
        j = len(s) - 1
    if i == j:
        return int(s[i] != c)

    mid = (i + j) // 2

    c1 = 0
    for idx in range(i, mid + 1):
        c1 += int(s[idx] != c)
    c1 += mc(s, mid + 1, j, chr(ord(c) + 1))

    c2 = 0
    for idx in range(mid + 1, j + 1):
        c2 += int(s[idx] != c)
    c2 += mc(s, i, mid, chr(ord(c) + 1))

    return min(c1, c2)


if __name__ == '__main__':
    for _ in range(int(input())):
        input()
        print(mc(list(input())))
