def Solve(sGoods, iLeft, iRight, iOrder):
    if iLeft == iRight:
        return 0 if sGoods[iLeft] == chr(iOrder) else 1
    iMid = (iLeft + iRight) >> 1
    iLeftSum = 0
    for idx in xrange(iLeft, iMid + 1, 1):
        if sGoods[idx] == chr(iOrder):
            iLeftSum += 1
    iRightSum = 0
    for idx in xrange(iMid + 1, iRight + 1, 1):
        if sGoods[idx] == chr(iOrder):
            iRightSum += 1
    return min((iMid - iLeft + 1) - iLeftSum +
               Solve(sGoods, iMid + 1, iRight, iOrder + 1),
               (iRight - iMid) - iRightSum +
               Solve(sGoods, iLeft, iMid, iOrder + 1))


def Main():
    tCase = int(raw_input().strip())
    for _ in xrange(tCase):
        n = int(raw_input().strip())
        sGoods = raw_input().strip()
        iAnswer = Solve(sGoods, 0, n - 1, ord('a'))
        print iAnswer


Main()