import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))
sys.setrecursionlimit(10**5)

def main():
	global s
	t,=I()
	for _ in range(t):
		n,=I()
		s=list(input())
		if n==1:
			print(1-int('a'==s[0]))
		else:
			def ck(ct,ix,cr):
				if ct==0:
					return 1-int(s[ix]==chr(cr))
				p=q=0 
				for i in range(ix,ix+ct):
					p+=(s[i]!=chr(cr))
				p+=ck(ct//2,ix+ct,cr+1)
				for i in range(ix+ct,ix+2*ct):
					q+=(s[i]!=chr(cr))
				q+=ck(ct//2,ix,cr+1)
				return min(p,q)
			p=ck(n//2,0,ord('a'))
			print(p)

main()