def dfs(l,r,char):
  if l==r:
    p=0
    if s[l]!=alp[char]:
      p+=1
    return(p)
  p=dfs((l+r+1)//2,r,(char+1)%26)
  for i in range(l,(l+r+1)//2):
    if s[i]!=alp[char]:
      p+=1
  q=dfs(l,(l+r+1)//2-1,(char+1)%26)
  for i in range((l+r+1)//2,r+1):
    if s[i]!=alp[char]:
      q+=1
  return(min(p,q))
alp='abcdefghijklmnopqrstuvwxyz'
t=int(input())
for _ in range(t):
  n=int(input())
  s=input()
  print(dfs(0,n-1,0))
  