from string import ascii_lowercase
from functools import lru_cache

for _ in range(int(input())):
	n = int(input())
	s = input()

	@lru_cache(maxsize=None)
	def f(i, j, ci):
		c = ascii_lowercase[ci]
		if j - i == 1: return int(c != s[i])

		m = (i + j) // 2

		return min((m - i) - s[i:m].count(c) + f(m, j, ci+1),
				   (j - m) - s[m:j].count(c) + f(i, m, ci+1))

	print(f(0, n, 0))
