def f(s,c):
  if len(s)==1:
    return 0 if s==c else 1
  s,t=s[:len(s)//2],s[len(s)//2:]
  return min(len(s)-t.count(c)+f(s,chr(ord(c)+1)),\
             len(t)-s.count(c)+f(t,chr(ord(c)+1)))
 
for _ in range(int(input())):
  n=int(input())
  s=input()
  print(f(s,"a"))