def f(c, i, j):
	global s
	# print c, i, j
	if i == j:
		r = 0 if s[i] == c else 1
		# print c, i, j, r
		return r
	m = (j-i+1)//2+i
	c1 = 0
	for k in xrange(i, m):
		if s[k] != c:
			c1 += 1
	c2 = 0
	for k in xrange(m, j+1):
		if s[k] != c:
			c2 += 1
	newC = chr(ord(c)+1)
	# print c1, c2, i, j, c
	r = min(f(newC, i, m-1)+c2, c1+f(newC, m, j))
	# print c, i, j, r
	return r

I=lambda: map(int, raw_input().split())
t = input()
for _ in xrange(t):
	n = input()
	s = raw_input()
	print f('a', 0, n-1)