def dfs (string, c_code):
	c = chr(c_code)

	if len(string) == 1:
		if string[0] == c:
			return 0
		else:
			return 1
	mid = len(string)//2
	left = mid - string[:mid].count(c) +   dfs(string[mid:], c_code+1)
	right = mid - string[mid:].count(c) +   dfs(string[:mid], c_code+1)
	return min(left, right)
	
t = int(input( ))
for _t in range(t):
	n = int(input( ))
	s = input()
	print(dfs(s, ord("a")))