def parser(leng, line, index, how):
	if not how:
		if leng %4 == 0:
			return leng//2-line[:leng//2].count(let[index])+min(parser(leng//2, line[leng//2:], index+1, False), parser(leng//2, line[leng//2:], index+1, True))
		else:
			if line[0] == let[index] and line[1] == let[index+1]:
				return 0
			elif line[0] == let[index]:
				return 1
			elif line[1] == let[index+1]:
				return 1
			else:
				return 2
	else:
		if leng %4 == 0:
			return leng//2-line[leng//2:].count(let[index])+min(parser(leng//2, line[:leng//2], index+1, False), parser(leng//2, line[:leng//2], index+1, True))
		else:
			if line[0] == let[index+1] and line[1] == let[index]:
				return 0
			elif line[1] == let[index]:
				return 1
			elif line[0] == let[index+1]:
				return 1
			else:
				return 2
let = 'abcdefghijklmnopqrstuvwxyz'
for i in range(int(input())):
	n = int(input())
	line = input()
	leng = len(line)
	if leng == 1:
		if line == 'a':
			print(0)
		else:
			print(1)
	else:
		res = min(parser(leng, line, 0, False), parser(leng, line, 0, True))
		print(res)
