def solve(lgo, rgo, lc, rc, v):
	#print lgo, rgo, lc, rc, v
	ans = 0
	for i in xrange(lgo, rgo+1):
		if ord(inp[i]) - ord('a') != v:
			ans += 1
 
	mid = (lc + rc) >> 1
 
	if(lc != rc):
		solveLeft = solve(lc, mid, mid+1, rc, v+1)
		solveRight = solve(mid+1, rc, lc, mid, v+1)
		ans += min(solveLeft, solveRight)
	else:
		for i in xrange(lc, rc+1):
			if ord(inp[i]) - ord('a') != v+1:
				ans += 1
 
	return ans
 
noCases = int(raw_input())
 
while(noCases > 0):
	noCases -= 1
 
	n = int(raw_input())
	inp = raw_input()
 
	if n == 1:
		if inp == "a":
			print 0
		else:
			print 1
	else:
		sz = len(inp)
		print min(solve(0, sz/2-1, sz/2, sz-1, 0), solve(sz/2, sz-1, 0, sz/2-1, 0))

