def solve(s,ch):
  if len(s)==1:
    if s[0]==ch:
      return 0
    else:
      return 1
  n=len(s)
  a=s[0:n//2]
  b=s[n//2:n]
  acount=a.count(ch)
  bcount=b.count(ch)
  ch=chr(ord(ch)+1)
  op1=len(a)-acount+solve(b,ch)
  op2=len(b)-bcount+solve(a,ch)
  return min(op1,op2)



for _ in range(int(input())):
  n=int(input())
  s=input()
  print(solve(s,'a'))
  
