def get_cnt(start,k,char,s):
	result = 0 
	for index in range(start,start + 2**k):
		if s[index] != char:
			result += 1 

	return result 

def f(start,k,char,s):
	if (k == 0):
		if s[start] == char:
			return 0 
		return 1 

	return min(get_cnt(start,k-1,char,s) + f(start + 2**(k-1),k-1,char + 1,s),f(start,k-1,char + 1,s) + get_cnt(start + 2**(k-1),k-1,char,s))

def solve():
	import sys 
	import math
	input = sys.stdin.readline 
	print = sys.stdout.write 
	t = int(input())
	while t > 0:
		n = int(input())
		s = [ord(char) - 97 for char in input().strip()]
		max_k = int(math.log2(n))
		print(f'{f(0,max_k,0,s)}')
		print('\n')

		t -= 1

solve()
