nCases = int(input())
alpha = "abcdefghijklmnopqrstuvwxyz"

def changeToLetter(string, sIndex, dIndex, good):
    letter = alpha[good]
    change = 0
    for i in range(sIndex, dIndex, 1):
        if string[i] != letter:
            change += 1
    return change

def changeToGood(string, sIndex, dIndex, good = 0):
    midpoint = int(((dIndex-sIndex) / 2) + sIndex)

    if midpoint == sIndex:
        n = changeToLetter(string, sIndex, dIndex, good)
        #print("single letter", string[sIndex], "to", alpha[good], "costs", n)
        return n


    nLeft = 0
    nLeft += changeToLetter(string, sIndex, midpoint, good)
    nLeft += changeToGood(string, midpoint, dIndex, good + 1)
    #print("To make", string[sIndex:dIndex], alpha[good], "Good on the Left  takes", nLeft, "changes")

    nRight = 0
    nRight += changeToLetter(string, midpoint, dIndex, good)
    nRight += changeToGood(string, sIndex, midpoint, good + 1)
    #print("To make", string[sIndex:dIndex], alpha[good], "Good on the Right takes", nRight, "changes")

    return min(nLeft, nRight)

for _ in range(nCases):
    sLen = int(input())
    s = list(input())
    changes = changeToGood(s, 0, sLen)
    print(changes)


  	 		 	 	  			 	 	 		 	 	 		