def ans(i,a,s):
	if a==1:
		if s ==q[i]:return 0
		else:return 1
	else:
		z,x=0,0
		r = s[0:a//2]
		t = s[a//2:a]
		for j in r:
			if j!=q[i]:z+=1
		for j in t:
			if j!=q[i]:x+=1
		return min(z+ans(i+1,a//2,t),x+ans(i+1,a//2,r))
q = list("abcdefghijklmnopqrstuvwxyz")
for _ in range(int(input())):
	a = int(input())
	s = input()
	print(ans(0,a,s))