def checkGoodString(string, char):
    if(len(string) == 1):
        return string[0] == char
    h = len(string)//2
    s1 = string[:h]
    s2 = string[h:]
    good = False
    for c in s1:
        if(c != char):
            break
    else:
        good = checkGoodString(s2, chr(ord(char) + 1))

    if(good):
        return True

    for c in s2:
        if(c != char):
            return False
    return checkGoodString(s1, chr(ord(char) +1))

def solve(string, char):
    #stop condition, only 1 char
    if(len(string) == 1):
        return 0 if string[0] == char else 1
    #stop condition, already char-good string
    if(checkGoodString(string, char)):
        return 0

    h = len(string)//2
    s1 = string[:h]
    s2 = string[h:]
    #try to solve first half
    dif = 0
    for c in s1:
        if(c != char):
            dif += 1
    dif += solve(s2, chr(ord(char)+1))
    #and the second half
    dif2 = 0
    for c in s2:
        if(c!= char):
            dif2+= 1
    dif2 += solve(s1, chr(ord(char)+1))

    #return the best solution
    return min(dif, dif2)

n = int(input())
for i in range(n):
    input()
    print(solve(input(),'a'))
 						 	 		      		 					 				