def dfs(s, c):
	if len(s) == 1:
		if s == c:
			return 0
		else:
			return 1
	else:
		mid = len(s)//2
		return min(mid - s[:mid].count(c) + dfs(s[mid::], chr(ord(c)+1)) ,\
		mid - s[mid::].count(c) + dfs(s[:mid], chr(ord(c)+1)))
def main():
	T = int(input())
	while T:
		n = int(input())
		s = str(input())
		ans = dfs(s, 'a')
		print(ans)
		T-=1

if __name__ == '__main__':
	main()