def solve(c, left, s, cur):
	if len(s) == 0:
		return
	l = len(s) // 2

	if left:
		if len(s) == 1:
			if s != c:
				cur += 1
			global mn
			mn = min(cur, mn)
			return
		else:
			for i in range(l):
				if s[i] != c:
					cur += 1
		j = ord(c[0])
		j += 1
		c = chr(j)
		if len(s) == 2:
			solve(c, 0, s[l:len(s)], cur)
		else:
			solve(c, 0, s[l:len(s)], cur)
			solve(c, 1, s[l:len(s)], cur)
	else:
		if len(s) == 1:
			if s != c:
				cur += 1
			mn = min(cur, mn)
			return
		else:
			for i in range(l, len(s)):
				if s[i] != c:
					cur += 1
		j = ord(c[0])
		j += 1
		c = chr(j)
		if len(s) == 2:
			solve(c, 1, s[0:l], cur)
		else:
			solve(c, 0, s[0:l], cur)
			solve(c, 1, s[0:l], cur)


t = int(input())
for j in range(t):
	n = int(input())
	s = input()
	mn = 100000000
	solve('a', 1, s, 0)
	solve('a', 0, s, 0)
	print(mn)