import os
	

t=int(input())
while t:
	t-=1
	n=int(input())
	s=input()
	x=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
	c=0
	ans=0
	while len(s)!=1:
		s1=[x[c]]*(len(s)//2)
		count1,count2=[0]*2
		for i in range(len(s1)):
			if s1[i]!=s[i]:
				count1+=1
			if s1[i]!=s[len(s1)+i]:
				count2+=1
		ans+=min(count1,count2)
		if count1<=count2:
			s=s[len(s1):]
		else:
			s=s[0:len(s1)]
		c+=1
	if s[0]!=x[c]:
		ans+=1
	print(ans)