t = int(input())

for i in range(t):

	n = int(input())

	s = input()

	# 0, n-1, a
	def recur(start, end, curr):
		if start == end:
			if s[start] == curr:
				return 0

			return 1

		mid = (start+end)//2

		startChange = 0
		for i in s[start:mid+1]:
			if i!=curr:
				startChange+=1

		endChange = 0

		for i in s[mid+1:end+1]:
			if i!=curr:
				endChange+=1

		nextChar = chr(ord(curr)+1)

		return min(startChange+recur(mid+1, end, nextChar), endChange+recur(start, mid, nextChar))

	print(recur(0, n-1, 'a'))