def a_good(n,s,ch):
	#print(s)
	#print(ch)
	if(n==1):
		if s==ch:
			return 0
		else:
			return 1
	mid = n//2
	left = s[:mid].count(ch)	
	right = s[mid:].count(ch)
	return min((mid-left)+a_good(mid,s[mid:],chr(ord(ch)+1)),(mid-right)+a_good(mid,s[:mid],chr(ord(ch)+1)))	

tt = int(input())
for _ in range(tt):
	n = int(input())
	s = input()
	print(a_good(n,s,'a'))
