def calc(s, low, high, ch):
	if low == high:
		if ch == s[low]:
			return 0
		else:
			return 1

	else:
		l = (high-low+1) // 2
		left_high, right_low = low + (l-1), low + l
		s1, s2 = s[low:left_high+1], s[right_low:high+1]

		v11 = list(filter(lambda x: x != ch, s1))
		v21 = list(filter(lambda x: x != ch, s2))

		v12 = calc(s, right_low, high, chr(ord(ch)+1))
		v22 = calc(s, low, left_high, chr(ord(ch)+1))

		return min(len(v11) + v12, len(v21) + v22)

if __name__ == '__main__':
	for t in range(int(input())):
		n = int(input())
		s = input()

		ans = calc(s, 0, n-1, 'a')
		print(ans)