def make_good(s, l):
	if len(s) == 1:
		if s[0] == l:
			return 0
		else:
			return 1
	else:
		left = s[0:int(len(s)/2)]
		right = s[int(len(s)/2):len(s)]
		ll = chr(ord(l) + 1)
		cl = count_l(left, l)
		ml = make_good(left, ll)
		cr = count_l(right, l)
		mr = make_good(right, ll)

		return min(cl + mr, cr + ml)

def count_l(s, l):
	return len(s) - s.count(l)

t = int(input())
for k in range(t):
	l = int(input())
	s = input()
	print(make_good(s, 'a'))