def func(s, n, i):
  if(n == 1):
    if(ord(s) == (97+i)):
      return 0
    else:
      return 1

  n /= 2

  c1 = 0
  for k in xrange(n):
    if(ord(s[k]) == (97+i)):
      c1 += 1
  
  c2 = 0
  for k in xrange(n, n*2):
    if(ord(s[k]) == (97+i)):
      c2 += 1

  i += 1
  pls = 0
  if(c1 > c2):
    pls += (n-c1)

    return func(s[n:],n,i) + pls
  elif(c2 > c1):
    pls += (n-c2)

    return func(s[:n],n,i) + pls
  else:
    pls += (n-c1)

    return min(func(s[n:],n,i),func(s[:n],n,i)) + pls
t = int(raw_input())

for q in xrange(t):
  n = int(raw_input())
  s = raw_input()

  print(func(s, n, 0))