def makeGood(ch, s, i, j):
	if i == j:
		if s[i] != ch:
			return 1
	
	if i >= j:
		return 0

	mid = (i + j) // 2
	c1 = s[i:mid + 1].count(ch)
	c2 = s[mid +  1:j + 1].count(ch)

	ch2 = chr(ord(ch) + 1)

	cost1 = mid - i + 1 - c1 + makeGood(ch2, s, mid + 1, j)
	cost2 = j - mid - c2 + makeGood(ch2, s, i, mid)

	return min(cost1, cost2)

for t in range(int(input())):
	n = int(input())
	s = input()
	print(makeGood('a', s, 0, len(s) - 1))

