def make_good(first, last, c, size):
	if last-first==1:
		if l[first:last]==[c] : return 0
		else: return 1
	return min(make_good(first+size//2, last, chr(ord(c)+1), size//2)+(  size//2-l[first:last-size//2].count(c)), make_good(first, last-size//2, chr(ord(c)+1),size//2)+(  size//2-l[ first+size//2:last].count(c)))

for _ in range(0, int(input())): 
	n = int(input())
	# x, y, z = map(int, input().strip().split())
	l = list(input().strip())
	print(make_good(0, n, "a", n))